According to the Homebrew site, to install it, I need to type:
brew install wgetI get an error message:
-bash: brew: command not foundFound this answer. The problem, however, is I don't see brew in /usr/local/bin.
I added the below line to my .bashrc file
export PATH=/usr/local/bin:$PATHStill getting the command not found error.
How do I install Homebrew on macOS?
322 Answers
It's on the top of the Homebrew homepage.
From a Terminal prompt:
/bin/bash -c "$(curl -fsSL )"The command brew install wget is an example of how to use Homebrew to install another application (in this case, wget) after brew is already installed.
Historic...
Before about 2020, the command given on the Homebrew page was:
ruby -e "$(curl -fsSL )" 7 If you are using m1 chip mac then run below command after installing homebrew and open the terminal again:
echo "export PATH=/opt/homebrew/bin:$PATH" >> ~/.zshrc 9 Check if Xcode is installed or not:
$ gcc --version
$ ruby -e "$(curl -fsSL )"
$ brew doctor
$ brew update"click here for exact instruction updates"
4How To Set Up Your Mac for Homebrew
Step 1
Check you have already Install the Xcode. Run the below command in your terminal
/usr/bin/xcodebuild -versionIt will print the below sample output:
Xcode 12.3 Build version 12C33
Step 2
Now Open Xcode:
- Select preferences
- Select location tab
- Now in command Line Tool select your Xcode version from dropdown menu
Step 3
In terminal run below command:
/bin/bash -c "$(curl -fsSL )"Note : if you have M1 Chip Mac run the below command, close terminal and open the terminal again
echo "export PATH=/opt/homebrew/bin:$PATH" >> ~/.zshrc 3 For Mac with Apple Silicon (M1), First export your path and enter the brew command.
export PATH=/opt/homebrew/bin:$PATH
brew I might be late to the party, but there is a cool website where you can search for the packages and it will list the necessary command to install the stuff.BrewInstall is the website.
However you can install wget with the following command:
ruby -e "$(curl -fsSL )"
brew install wgetHope this helps :)
For m1 mac, use this command and restart the terminal.
1echo "export PATH=/opt/homebrew/bin:$PATH" >> ~/.zshrc
On an out of the box MacOS High Sierra 10.13.6
$ ruby -e "$(curl -fsSL )"Gives the following error:
curl performs SSL certificate verification by default, using a "bundle" of Certificate Authority (CA) public keys (CA certs). If the default bundle file isn't adequate, you can specify an alternate file using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in the bundle, the certificate verification probably failed due to a problem with the certificate (it might be expired, or the name might not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use the -k (or --insecure) option.
HTTPS-proxy has similar options --proxy-cacert and --proxy-insecure.
Solution: Just add a k to your Curl Options
$ ruby -e "$(curl -fsSLk )" 3 Brew has now been rewritten in Bash!
/bin/bash -c "$(curl -fsSL )" 1 Here is a version that wraps the homebrew installer in a bash function that can be run from your deployment scripts:
install_homebrew_if_not_present() { echo "Checking for homebrew installation" which -s brew if [[ $? != 0 ]] ; then echo "Homebrew not found. Installing..." ruby -e "$(curl -fsSL )" else echo "Homebrew already installed! Updating..." brew update fi
}And another function which will install a homebrew formula if it is not already installed:
brew_install () { if brew ls --versions $1 > /dev/null; then echo "already installed: $1" else echo "Installing forumula: $1..." brew install $1 fi
}Once you have these functions defined you can use them as follows in your bash script:
install_homebrew_if_not_present
brew_install wget
brew_install openssl
... I faced the same problem of brew command not found while installing Homebrew on mac BigSur with M1 processor.
I - Install XCode if it is not installed yet.
II - Select terminal.app in Finder.
III - RMB click on Terminal and select "Get Info"
IV - Select Open using Rosetta checkbox.
V - Close any open Terminal windows.
VI - Open a new Terminal window and install Hobebrew:
/bin/bash -c "$(curl -fsSL )"VII - Test Homebrew installation.
IIX - Uncheck Open using Rosetta checkbox.
0first, install the homebrew by pasting the command in the mac terminal
ruby -e "$(curl -fsSL )" then edit your .bashrc file
vi .bashrcpaste the below command at the end and save it
export PATH=/opt/homebrew/bin:$PATHto save simply type :wq and press enter
if bashrc file is not there then simply create and then edit the file, to create type
touch ~/.bashrcand then simply run the command
source ~/.bashrcnow try to use the brew command hopefully it will work now
Update: if you are in M1 mac then after installing homebrew just run the command mentioned below and reload the terminal
echo "export PATH=/opt/homebrew/bin:$PATH" >> ~/.zshrc If you still get error after running,
ruby -e "$(curl -fsSL )"Then try to download and install command line tool from for your particular Mac os and Xcode version.
Then try to run,
/usr/bin/ruby -e "$(curl -fsSL )"and then
brew install node 1 Open Terminal and put below command.
Install:
/usr/bin/ruby -e "$(curl -fsSL )"Uninstall:
ruby -e "$(curl -fsSL )"Once install complete after entering brew commands:
brew install wget
brew install node
brew install watchman
...
... You can install brew using below command.
ruby -e "$(curl -fsSL )"However, while using this you will get warning that it buy homebrew installer is now deprecated. Recommended to use Bash instead.
/bin/bash -c "$(curl -fsSL )" Following command doesn't work if your are under proxy.
ruby -e "$(curl -fsSL )"
Instead user following -
ruby -e "$(curl -x -fsSL )"Note we have to use %5c instead of "\" Similarly if your password has any special character replace it with unicode e.g for @ use %40 Refer this Unicodes
Replace above command with your own params
DOMAIN - Your Domain
USER_NAME - Your User Name
PASSWORD - password
PROXY - 10.10.10.10
PORT - 8080
1macOS Big Sur
Had to add this to Terminal cmd to get Brew running.
Add Homebrew to your PATH in /Users/*username/.zprofile:
echo 'eval $(/opt/homebrew/bin/brew shellenv)' >> /Users/*username/.zprofile eval $(/opt/homebrew/bin/brew shellenv)
*username = your local machine username
Resolve " -bash: brew: command not found "
- Add Homebrew to your PATH in /Users//.bash_profile:
echo 'eval $(/opt/homebrew/bin/brew shellenv)' >> /Users//.bash_profile
eval $(/opt/homebrew/bin/brew shellenv) add the following in your terminal and click enter then follow the instruction in the terminal. /usr/bin/ruby -e "$(curl -fsSL )"
Not sure why nobody mentioned this : when you run the installation command from the official site, in the final lines you would see something like below, and you need to follow the ==> Next steps:
==> Installation successful!
==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
Read the analytics documentation (and how to opt-out) here:
No analytics data has been sent yet (or will be during this `install` run).
==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
==> Next steps:
- Add Homebrew to your PATH in /Users/{YOUR USER NAME}/.bash_profile: echo 'eval $(/opt/homebrew/bin/brew shellenv)' >> /Users/{YOUR USER NAME}/.bash_profile eval $(/opt/homebrew/bin/brew shellenv)This is for bash shell. You will see different steps for every different shell, but the source of the steps are same.
After I had tried everything described, I looked up into the folder permission of brew in /usr/local/etc/. Somehow the permission were changed and I was not able to open the folder. I changed the folder permissions(with chmod) with same permissions as the other folders and brew start working.
1Here's the script:
1/usr/bin/ruby -e "$(curl -fsSL )"