Homebrew is a package manager. It supports a Linux since version 2.0 and it also supports the WSL.
This article explains how to setup Homebrew in WSL.
About Homebrew
Homebrew can
- Install dependencies at once.
- Updates and uninstall packages easily
Homebrew following steps with 1 command.
- Download a package.
- Download dependencies.
- Install them with valid order.
- Generate and execute needed scripts.
Benefits on WSL
Linux distributions on WSL has a package manage. Are there any befits Homebrew has? Yes.
- Homebrew independent from the Linux distribution.
- Homebrew install packages into the user’s home directory.
Linux distributions on WSL has apt-get. It is a standard package manager and can install any packages easily. However, supported packages are dependent on the distribution. Homebrew is not dependent on the distribution.
System requirements
Homebrew is running on WSL (Windows Subsystem for Linux) . WSL is a compatible layer to execute linux binaries on Windows. Homebrew officially support WSL not Windows directly.
You must install the WSL before setup Homebrew. I wrote how to setup the WSL in the post below.
Install the Homebrew
Open the shell in the WSL. Open the web site of the Homebrew and copy the install script (only 1 line!), execute it in the shell. Password prompt will be appeared, enter the password of the Unix account.
Press “RETURN” key if you see the prompt below.
Press RETURN to continue or any other key to abort
Installing process will be began.
Execute the script is available at “Install” in next page to set the PATH environment value.
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
Execute next command.
$ brew install hello
Error was reported when developer tool is not installed
My machine reported the error below.
Error: patchelf must be installed: brew install patchelf
Warning: Bottle installation failed: building from source.
Error: The following formula
patchelf
cannot be installed as binary package and must be built from source.
Install Clang or run `brew install gcc`.
Homebrew build from source files when binaries are not usable, so the developer tool is needed.
I tried to install the gcc.
$ brew install gcc
But it failed and the error message was same.
Install Clang
Install the Clang with apt-get. You can install the gcc instead of Clang.
$ sudo apt-get update
$ sudo apt-get install clang
Try again
I installed the developer tool and try again.
$ brew install hello
Execute it.
$ hello
Hello, world!
Author Profile

- A professional developer specializing in macOS Apps, iOS Apps, SDKs and middleware development.
- Representative of RK Kaihatsu. I am a professional developer specializing in macOS Apps, iOS Apps, SDKs and middleware development. I often use ObjC, Swift and C++. Based on development experience, I provide e-learning contents, technical books and technical guidance. I am also a technical seminar instructor, in-house training instructor, and administrative / local goverment staff training instructor.