Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Install Homebrew on Windows WSL Ubuntu, and fix "zsh: brew command not found" error

Installation was a series of 5 simple steps:

first, install homebrew itself from command in the home page:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

After that, following instructions in this page, and changing ~/.bash_profile to ~/.profile as I am using Ubuntu as my wsl distro, i had to give these commands:

test -d ~/.linuxbrew && eval $(~/.linuxbrew/bin/brew shellenv)
test -d /home/linuxbrew/.linuxbrew && eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
test -r ~/.profile && echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.profile
echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.profile

But now, when I try to run brew, I get command not found error.

like image 812
Somjit Avatar asked Nov 04 '20 13:11

Somjit


People also ask

Can I use Homebrew with zsh?

If the zsh shell that Apple provides in Mac OS X is out of date, as it has been in Yosemite and El Capitan, it's trivial to install the latest version, available on homebrew . Here's a couple of steps you need to do to make that your default. Read on, for how to do it.

Is Homebrew available for Ubuntu?

Install Homebrew on Ubuntu and other Linux distributions The installation is quite easy. You just have to make sure that you have got all the dependencies.


1 Answers

In a wsl environment, brew is installed at location: /home/linuxbrew/.linuxbrew/ which is not part of the path.

So we simply need to add that to path, and it works. I am using zsh as my shell, so I add these lines to my ~/.zshrc file (in ubuntu file system) :

export BREW_HOME="/home/linuxbrew/.linuxbrew/bin"
export PATH="$PATH:$BREW_HOME"
like image 169
Somjit Avatar answered Sep 22 '22 23:09

Somjit