How To Install Brew on WSL
2 min read

Brew on WSL

Installing and configuring Brew on WSL is not quite as easy as on, for example, MacOS. You need to configure some files and add paths yourself, this is how.

Start by installing Brew the normal way.

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

Now we need to configure our ~/.profile and add linuxbrew to our path. Just run these 4 commands.

test -d ~/.linuxbrew && eval $(~/.linuxbrew/bin/brew shellenv)

test -d /home/linuxbrew/.linuxbrew && eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)

test -r ~/.bash_profile && echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.bash_profile

echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.profile

Patchelf fix

You might be getting an error about patchelf, this is the simple fix:

sudo apt-get update
sudo apt-get install build-essential

Use on another shell than Bash

Many people use other shells than Bash, for example zsh. If you use that, remember to source ~/.profile in your ~/.zshrc file.