Brew command not found windows
In February 2021, Homebrew was officially supported for Windows and Linux OS also. Still, it was only compatible with specific versions of both OS. But it is not as simple as it sounds. Homebrew works on Subsystems of Windows for Linux. So if you have installed Homebrew for your Windows subsystem and see an error of command not found, then after going through this article, you will be able to solve it quickly.
Windows Subsystem for Linux
The Windows Subsystem for Linux allows developers to run a GNU/Linux environment including most command-line tools, utilities, and applications directly on Windows, unmodified, without the overhead of a traditional Virtual Machine(VM) or dual boot setup. Moreover, It’s designed to be a seamless experience, essentially providing an entire Linux shell that can interact with your Windows file system.
WSL is intended to give developers and bash veterans the Linux shell experience despite using Windows as the primary OS. It offers the best of both worlds by allowing you to run Windows apps, like Visual Studio, alongside a Linux shell for easier command-line access.
Microsoft offers two versions of WSL: version 1 and version 2. WSL 2 uses a virtual machine and uses an entire Linux kernel built and shipped with Windows. WSL 1 is older and competitively slower, but it performs better when working across filesystems. For example: accessing Windows files from Linux and vice versa. It recommends WSL 2 for operations, as it’s faster, reliable, and works much better with tools like Docker.
How to install WSL?
You must be running Windows 10 version 2004 or Windows 11. If you’re running an older build or prefer not to use the install command and would like step-by-step directions, see WSL manual installation steps for older versions.
Installing WSL
You can now install everything you need to run Windows Subsystem for Linux (WSL) by entering this command in an administrator PowerShell or Windows Command Prompt and then restarting your machine. First, press Windows key Button + R to popup the command prompt, type “cmd” and hit enter. After this copy, the script is given below:
wsl –install
“This requested operation requires elevation” error
[Fix: If you see this message after entering the script, here’s what to do. First, press the Windows key on your keyboard, then type cmd (DON’T press Enter). Windows will display a list of programs that match your search. Next, right-click Command Prompt and choose Run as administrator.]
This command will allow the required, optional components to install on the hard drive. It will automatically download the latest Linux kernel. Then set WSL 2 as your default, and install a Linux distribution for you. The first time you launch a newly installed Linux distribution, a console window will open, and you’ll be asked to wait for files to decompress and be stored on your machine. All future launches should take less than a second.
Change the default distribution.
By default, the installed Linux distribution will be based upon Ubuntu. This can be changed using the -d flag command script:
- To change the distribution installed, enter: wsl –install -d <Distribution Name>. Replace <Distribution Name> with the name of the distribution you would like to install.
- To see a list of available Linux distributions available for download through the online store, enter wsl –list –online or wsl -l -o
- To install additional Linux distributions after the initial install, you may also use the command: wsl –install -d <Distribution Name>.
Tip
Suppose you want to install additional distributions inside a Linux/Bash command line (rather than from PowerShell or Command Prompt). In that case, you must use .exe in the script: wsl.exe –install -d <Distribution Name> or if you want to see the list of available distributions, use this script: wsl.exe -l -o.
If you encountered an issue during the installation process, check the installation section of the troubleshooting guide from Microsoft.
Set up your Linux user info
Once you have installed WSL successfully, you will need to create a user account and password for your newly installed Linux distribution. Execute the command sudo adduser <username> .
- Substitute the <username> portion with the actual user name you want to create.
- Type your current password when prompted.
Set up and best practices
We recommend Microsoft’s Best practices for setting up a WSL development environment guide for a step-by-step walk-through of how to set up a username and password for your installed Linux distribution(s), by using basic WSL commands, installing and customizing Windows Terminal, setting up for Git version control, debugging and code editing using the VS Code remote server, good practices for file storage, setting up a database, mounting an external drive, setting up GPU overclocking, and much more. The link will guide you about each step to complete your profile for Homebrew.
Preview the latest WSL features?
Try the most recent features or updates to WSL by joining the Windows Insiders Program. Once you have joined Windows Insiders, you can choose the channel you would like to receive preview builds from inside the Windows settings menu to automatically receive any WSL updates or preview features associated with that build. You can choose from:
- Dev channel: Low stability but frequently offers updates.
- Beta channel: Ideal for early users, more reliable builds than the Dev channel.
- Release Preview channel: Offer key features and preview fixes on the next version of Windows just before it’s available to the general public.
How to install Homebrew on Windows without any error?
Step 1: Open Terminal and run system update command:
According to your Linux distro on Desktop or server, run the system update command, here we will let you know the most common ones.
For Ubuntu & Debian based systems:
sudo apt update
RedHat or CentOS based:
sudo yum update
Step 2: Install Brew Dependencies
To set up Brew, we need to have the following things on our system- GCC, Glibc, and 64-bit x86_64 CPU. I am sure you are already on a 64-bit CPU which is common nowadays. For the rest of things, use the below commands as per your system.
For Debian, Linux Mint, Ubuntu, or other similar OS
sudo apt-get install build-essential curl file git
For RedHat, Fedora, CentOS, or other same kinds of Linux OS
sudo yum groupinstall ‘Development Tools
sudo yum install curl file git
sudo yum install libxcrypt-compat
Step 3: Command to download and install HomeBrew
To set up Brew on Linux or WSL, you need to download the master script file.
sh -c “$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)”
Step 4: Add Homebrew to your system PATH
If you want to run the brew command of this package manager from anywhere in the terminal, regardless of any directory you are located in. You will have to command the system to add it to the BIN repository. Run the following command on your Linux system one by one to add Homebrew to your system PATH.
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
Homebrew Command not Found error fix
In a wsl environment, Brew is installed at location:
/home/linuxbrew/.linuxbrew/
which is not part of the path nor the directory.
So we need to add that to the correct path, and it works. Use zsh as the default shell so you can add these lines to
~/.zshrc
export BREW_HOME=”/home/linuxbrew/.linuxbrew/bin”
export PATH=”$PATH:$BREW_HOME”
These commands will redirect the Path variable and remove the command not found error from Brew in WSL.
Note: If you have tried to use these commands below, these will not work at all:
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
Conclusion
We discussed fixing the brew command error in Windows and the script to fix the command not found error. We hope you find this article helpful and will help you solve your problem.
Brew command not found windows
In February 2021, Homebrew was officially supported for Windows and Linux OS also. Still, it was only compatible with specific versions of both OS. But it is not as simple as it sounds. Homebrew works on Subsystems of Windows for Linux. So if you have installed Homebrew for your Windows subsystem and see an error of command not found, then after going through this article, you will be able to solve it quickly.
Windows Subsystem for Linux
The Windows Subsystem for Linux allows developers to run a GNU/Linux environment including most command-line tools, utilities, and applications directly on Windows, unmodified, without the overhead of a traditional Virtual Machine(VM) or dual boot setup. Moreover, It’s designed to be a seamless experience, essentially providing an entire Linux shell that can interact with your Windows file system.
WSL is intended to give developers and bash veterans the Linux shell experience despite using Windows as the primary OS. It offers the best of both worlds by allowing you to run Windows apps, like Visual Studio, alongside a Linux shell for easier command-line access.
Microsoft offers two versions of WSL: version 1 and version 2. WSL 2 uses a virtual machine and uses an entire Linux kernel built and shipped with Windows. WSL 1 is older and competitively slower, but it performs better when working across filesystems. For example: accessing Windows files from Linux and vice versa. It recommends WSL 2 for operations, as it’s faster, reliable, and works much better with tools like Docker.
How to install WSL?
You must be running Windows 10 version 2004 or Windows 11. If you’re running an older build or prefer not to use the install command and would like step-by-step directions, see WSL manual installation steps for older versions.
Installing WSL
You can now install everything you need to run Windows Subsystem for Linux (WSL) by entering this command in an administrator PowerShell or Windows Command Prompt and then restarting your machine. First, press Windows key Button + R to popup the command prompt, type “cmd” and hit enter. After this copy, the script is given below:
wsl –install
“This requested operation requires elevation” error
[Fix: If you see this message after entering the script, here’s what to do. First, press the Windows key on your keyboard, then type cmd (DON’T press Enter). Windows will display a list of programs that match your search. Next, right-click Command Prompt and choose Run as administrator.]
This command will allow the required, optional components to install on the hard drive. It will automatically download the latest Linux kernel. Then set WSL 2 as your default, and install a Linux distribution for you. The first time you launch a newly installed Linux distribution, a console window will open, and you’ll be asked to wait for files to decompress and be stored on your machine. All future launches should take less than a second.
Change the default distribution.
By default, the installed Linux distribution will be based upon Ubuntu. This can be changed using the -d flag command script:
- To change the distribution installed, enter: wsl –install -d <Distribution Name>. Replace <Distribution Name> with the name of the distribution you would like to install.
- To see a list of available Linux distributions available for download through the online store, enter wsl –list –online or wsl -l -o
- To install additional Linux distributions after the initial install, you may also use the command: wsl –install -d <Distribution Name>.
Tip
Suppose you want to install additional distributions inside a Linux/Bash command line (rather than from PowerShell or Command Prompt). In that case, you must use .exe in the script: wsl.exe –install -d <Distribution Name> or if you want to see the list of available distributions, use this script: wsl.exe -l -o.
If you encountered an issue during the installation process, check the installation section of the troubleshooting guide from Microsoft.
Set up your Linux user info
Once you have installed WSL successfully, you will need to create a user account and password for your newly installed Linux distribution. Execute the command sudo adduser <username> .
- Substitute the <username> portion with the actual user name you want to create.
- Type your current password when prompted.
Set up and best practices
We recommend Microsoft’s Best practices for setting up a WSL development environment guide for a step-by-step walk-through of how to set up a username and password for your installed Linux distribution(s), by using basic WSL commands, installing and customizing Windows Terminal, setting up for Git version control, debugging and code editing using the VS Code remote server, good practices for file storage, setting up a database, mounting an external drive, setting up GPU overclocking, and much more. The link will guide you about each step to complete your profile for Homebrew.
Preview the latest WSL features?
Try the most recent features or updates to WSL by joining the Windows Insiders Program. Once you have joined Windows Insiders, you can choose the channel you would like to receive preview builds from inside the Windows settings menu to automatically receive any WSL updates or preview features associated with that build. You can choose from:
- Dev channel: Low stability but frequently offers updates.
- Beta channel: Ideal for early users, more reliable builds than the Dev channel.
- Release Preview channel: Offer key features and preview fixes on the next version of Windows just before it’s available to the general public.
How to install Homebrew on Windows without any error?
Step 1: Open Terminal and run system update command:
According to your Linux distro on Desktop or server, run the system update command, here we will let you know the most common ones.
For Ubuntu & Debian based systems:
sudo apt update
RedHat or CentOS based:
sudo yum update
Step 2: Install Brew Dependencies
To set up Brew, we need to have the following things on our system- GCC, Glibc, and 64-bit x86_64 CPU. I am sure you are already on a 64-bit CPU which is common nowadays. For the rest of things, use the below commands as per your system.
For Debian, Linux Mint, Ubuntu, or other similar OS
sudo apt-get install build-essential curl file git
For RedHat, Fedora, CentOS, or other same kinds of Linux OS
sudo yum groupinstall ‘Development Tools
sudo yum install curl file git
sudo yum install libxcrypt-compat
Step 3: Command to download and install HomeBrew
To set up Brew on Linux or WSL, you need to download the master script file.
sh -c “$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)”
Step 4: Add Homebrew to your system PATH
If you want to run the brew command of this package manager from anywhere in the terminal, regardless of any directory you are located in. You will have to command the system to add it to the BIN repository. Run the following command on your Linux system one by one to add Homebrew to your system PATH.
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
Homebrew Command not Found error fix
In a wsl environment, Brew is installed at location:
/home/linuxbrew/.linuxbrew/
which is not part of the path nor the directory.
So we need to add that to the correct path, and it works. Use zsh as the default shell so you can add these lines to
~/.zshrc
export BREW_HOME=”/home/linuxbrew/.linuxbrew/bin”
export PATH=”$PATH:$BREW_HOME”
These commands will redirect the Path variable and remove the command not found error from Brew in WSL.
Note: If you have tried to use these commands below, these will not work at all:
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
Conclusion
We discussed fixing the brew command error in Windows and the script to fix the command not found error. We hope you find this article helpful and will help you solve your problem.