1. Home
  2. Windows

How to install Homebrew on Windows Subsystem for Linux on Windows 10

Linux is a part of Windows 10 and it is easily one of the biggest features to have come to Windows since its inception. It’s big for Windows 10, but no previous version of Windows had Linux so it’s a milestone like no other. There are still some limitations that remain but Microsoft has been improving WSL with each major feature update. If you’re using WSL on Windows 10, you may want to, at some point install Homebrew on it.

Homebrew is an essential app on Linux so it stands to reason that you might need it on WSL as well. Here’s how you can install Homebrew on Windows Subsystem for Linux.

Enable WSL & install Linux

Before you can install Homebrew on Windows Subsystem for Linux, you need to enable it and install a Linux OS on Windows 10. You can use any of the Linux operating systems that are available and the commands given below will work. For this post, we’re going with Ubuntu for Windows 10. It was the first ever OS to be supported for Windows 10 and will by far be the best in terms of features and stability.

Install Homebrew

Open whichever Linux OS you’ve installed on Windows 10 by searching for it in Windows Search or by launching it from the Start Menu.

Run the following command;

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

The command can take anywhere between 10-20 minutes to complete. You will have to enter your Linux password, and confirm the installation of some components during installation.

Once Homebrew has been installed, you will see a message telling you that /home/linuxbrew/.linuxbrew/bin is not in your PATH. This is easily fixed.

Run the following commands, and they will take care of everything.

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

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

These commands complete within seconds. Once they’re done, you can start using Homebrew in WSL.

When to use Homebrew?

In WSL, you can install apps from the software center of whichever Linux OS you’re running however, in some cases, the app may not install. In that case, it’s always worth giving Homebrew a try. If there’s an app that you simply cannot install from the software center i.e., it isn’t available there, Homebrew might be the only way to install it.

If you want to uninstall Homebrew, you can try the uninstall command but given this is WSL, it might be better to do a clean install of your Linux OS instead. As we said before, WSL still has some limitations.

Leave a comment