How to Install Homebrew on Mac

Mar 7, 2018 - 31 Comments

Install Homebrew on Mac

Advanced Mac users may appreciate using the Homebrew package manager, which greatly simplifies the process of installing command line software and tools on a Mac.

For example, if you want to easily install favorite command line tools on a Mac like cask, htop, wget, nmap, tree, irssi, links, colordiff, or virtually any other familiar unix command line utility, you can do so with a simple command. Homebrew downloads and builds the package for you.


This is obviously aimed at more technically savvy Mac users who spend a lot of time at the command line. While there’s no particular issue for novice users installing Homebrew on their Mac, the odds of novices finding it useful are slim, unless they intend to embark on learning the command line environment. Contrast that to power users who practically live in a terminal environment, whether longtime Mac users or migrating to the platform from the Windows or Linux world, who will immediately see the value of Homebrew.

Requirements for Installing Homebrew on Mac OS

prerequisites to installing Homebrew on a Mac include the following:

  • A Mac running Mac OS X 10.10 or later, though earlier versions are sort of supported
  • Command Line Tools must be installed on the Mac (either independently or through Xcode)
  • Knowledge of the command line and using bash or zsh

Assuming you’re interested in installing Homebrew and meet those requirements, then the rest is equally straight forward.

How to Install Homebrew on Mac OS

The simplest way to install Homebrew is through ruby and curl, accomplished with a single command. This approach is the same for installing Homebrew in all supported versions of Mac OS and Mac OS X.

  1. Open the “Terminal” application, found in /Applications/Utilities/
  2. Enter the following command into a single line of the terminal:
  3. For MacOS Ventura, MacOS Monterey:
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

    For MacOS Catalina, macOS Mojave, and MacOS Big Sur:
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

    For macOS High Sierra, Sierra, El Capitan, and earlier:
    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    Installing Homebrew on Mac

  4. Hit Return and you’ll see a series of lines about what the script will install and where, hit Return again to agree or hit Escape to cancel
  5. Enter the administrator password (required by sudo execution) to begin installation

Installation of Homebrew will take a while depending on the speed of your Mac and internet connection, as each necessary package is downloaded and installed by the script.

When complete, you will see an “Installation successful!” message.

Homebrew successfully installed on Mac

Now you’re ready to install software packages through Homebrew, or you can read the help documentation with the following command:

brew help

Homebrew help on Mac

Installing Software Packages through Homebrew on Mac

Installing packages with Homebrew is super easy, just use the following syntax:

brew install [package name]

For example, to install wget through Homebrew you could use the following syntax:

brew install wget

Simple, easy. Once complete you can run wget as usual.

Installing a package with Homebrew on Mac

A quick side note; Homebrew is not the only way to install command line software, you can install command line tools on a Mac yourself and then compile and make software independently. For example, we discuss installing wget on Mac OS without Homebrew here and it uses the typical configure and make process. There’s nothing wrong with that approach (and arguably it might be preferable for users who want limited packages and a slimmer footprint) but if you’re accustomed to a package manager like dpkg, apt-get, or rpm you’ll almost certainly appreciate and prefer to use Homebrew.

How to Disable Homebrew Analytics Tracking

Homebrew now defaults to using anonymized behavioral analytics tracking. If you do not want to participate in that or you’d just rather disable the feature to reduce network traffic or for privacy purposes, or whatever other reason, you can run the following command after successfully installing Homebrew on a Mac. This will opt out of Homebrew analytics:

brew analytics off

Hit return and after a moment or so the analytics tracking in Homebrew will be disabled.

How to Remove HomeBrew from a Mac

If you have installed Homebrew but later decide you want to remove Homebrew from a Mac for some reason or another, you can uninstall it with another ruby script run from the command line, choose the script that aligns with your version of MacOS:

Removing Homebrew in MacOS Catalina, macOS Big Sur, and MacOS Mojave:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)"

Removing Homebrew from MacOS High Sierra, Sierra, El Capitan, and earlier:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

Alternatively, you could download that “uninstall” script directly and run it yourself.

Enjoy Homebrew!

.

Related articles:

Posted by: Paul Horowitz in Command Line, Mac OS, Tips & Tricks

31 Comments

» Comments RSS Feed

  1. Manuel Rey says:

    Trying to install homebrew on my laptop running ventura 13.2. Installation fails with this message. Operation not permitted Failed during: /usr/bin/sudo /usr/sbin/chown -R user:admin /usr/local/Homebrew
    Tried a lot of things so far no dice, still can’t install homebrew in my laptop. Any help would be appreciated.

    Thanks,

    Manuel Rey

  2. copykatz says:

    Had to reinstall High Sierra on a 2012 MBP. I successively intalled homebrew in the past, but now I keep getting:

    ==> Checking for `sudo` access (which may request your password)…
    sudo: /etc/sudoers is world writable
    sudo: no valid sudoers sources found, quitting
    sudo: unable to initialize policy plugin
    Need sudo access on macOS (e.g. the user XXX needs to be an Administrator)!
    sudo: /etc/sudoers is world writable
    sudo: no valid sudoers sources found, quitting
    sudo: unable to initialize policy plugin

    I’m showing as the machine admin so I’m not sure why it’s now failing for me. I really need to install telnet, and homebrew seems the best way to do it.

    • x128 says:

      On legacy Os X lion 10.7 btw
      i tried
      this and
      tar xz –strip 1 -C /Users/mothafaka/Downloads/brew-1.5.2.tar.gz
      Nothing works, homebrew deprecated for lion i quess
      btw worth installing sierra on Mac Pro? (just ask, w93ts)
      (btw audius-dl-py stopped working for me on windows)

      “`
      sudo su
      export PATH=/usr/local/homebrew:$PATH
      mkdir homebrew && curl -L
      https://github.com/Homebrew/homebrew/tarball/master | tar xz –strip
      1 -C homebrew
      (releases???)
      /

      tar xz –strip 1 -C /Users/mothafaka/Downloads/brew-1.5.2.tar.gz
      Fail

      “`
      Anyway to copy it manually???

  3. Vishal says:

    Hi All,
    Whenever I try to install nvm, I am getting below ERROR. What might be cause.

    ==> Searching for similarly named formulae…
    Error: No similarly named formulae found.
    Error: No available formula or cask with the name “nvm”.
    ==> Searching for a previously deleted formula (in the last month)…
    Error: No previously deleted formula found.
    ==> Searching taps on GitHub…

  4. Chuck says:

    Running macOS Catalina v10.15.7, have updated XCode and command line tools but getting an error for github. Any ideas?

    ==> /usr/bin/sudo /usr/sbin/chown chuckrobertson:admin /usr/local/Homebrew
    ==> Downloading and installing Homebrew…
    git@github.com: Permission denied (publickey).
    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights
    and the repository exists.
    Failed during: git fetch –force origin

  5. jimmy davis says:

    My mac system is saying Error: Git must be installed and in my path before i can install homebrew and have installed git on my mac but its not still working

  6. Pete says:

    On Big Sur I had to add .sh at the end.

    % /bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
    /bin/bash: line 2: STDERR.print: command not found
    /bin/bash: line 9: Kernel.exec: command not found

  7. RogieRog says:

    I’m having no success installing Homebrew on my MBP running 10.14.6. This is what I get:

    Last login: Mon Nov 23 15:08:10 on ttys000
    RPGs-MacBook-Pro:~ rpg$ ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
    curl: (60) SSL certificate problem: self signed certificate in certificate chain
    More details here: https://curl.haxx.se/docs/sslcerts.html

    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.
    RPGs-MacBook-Pro:~ rpg$

    Thoughts?

    • Paul says:

      You might want to make sure your computer clock is set accurately, sometimes if it’s off or wrong, it can trigger SSL issues.

      It could also be a temporary problem with the SSL cert itself, so simply trying again in a few hours (or longer) may resolve the issue on its own.

  8. KYU says:

    Am getting the following message.
    Homewbrew did not install.
    It’s for a Mac, running macOS Catalina v10.15.7
    Unstall and re-install many times … looking, modied the read-write for folders and files …
    Anyone any idea please ?

    Press RETURN to continue or any other key to abort
    ==> Downloading and installing Homebrew…
    error: could not lock config file /usr/local/Homebrew/.git/config: Permission denied
    fatal: could not set ‘core.repositoryformatversion’ to ‘0’
    Failed during: git init -q

  9. Jordan says:

    I’m getting this line and nothing more…

    HEAD is now at 06f078fad Merge pull request #8072 from maxim-belkin/utf8-fix

  10. sunil says:

    hit return means which button

  11. JerM says:

    FYI, Catalina (v10.15.4) deprecated the Ruby installer and switched to Bash. You’ll get a warning if you try to install Brew with your Ruby command and instead direct you to use:

    /bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)”

    • Mark says:

      It’s not limited to Catalina.

      We got the same message on Mojave version 10.14.6 as well. Perhaps OSXDaily can update this article with both version for different users.

      • Paul says:

        For installing Homebrew in MacOS Big Sur, MacOS Catalina, and MacOS Mojave, try the following:

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

        Article has been updated to reflect this, thanks for the comments!

  12. Manivannan ManiMaran says:

    I need a help totally fu*kedup my MacBook

  13. Jay says:

    I got to the point of needing a password. I know my password, but there doesn’t seem to be a spot to type it…there’s no cursor/box/etc and nothing happens when I type. Help?

  14. George says:

    Any idea why I would get the message “Illegal variable name” when I enter

    /usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”

    on the Terminal command line?

  15. Voyageur says:

    Running macOS X 10.13.6 and get the following message in Terminal when trying to install Homebrew:

    Illegal variable name.

    Xcode and Command Line Tools are installed.

    Ideas? Thanks.

    • Paul says:

      Check your syntax, there may be something wrong in the typed syntax itself if you are seeing an illegal variable name error when trying to run the initial installer for Homebrew.

      Try using this code exactly as typed:

      /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

      Remember that syntax at the command line has to be exact and precise, one small letter difference is enough to make something not work as intended (or at all).

      Hope that helps!

  16. andrew says:

    it is cool

  17. macptyho says:

    Great tutorial, thanks. Other helpful Homebrew tips include;

    brew doctor

    and

    brew info packagename

  18. naser says:

    Hellow,
    I couldn’t install homebrew on mac OS X 10.8.5.
    In the terminal I have the following message of error. Can you please help about this problem. Thank you…

    curl: (35) error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version
    Failed during: /bin/bash -o pipefail -c ‘/usr/bin/curl -fsSL https://github.com/Homebrew/brew/tarball/master | /usr/bin/tar xz -m –strip 1′

    • mapytho says:

      For installing Homebrew on Mac OS / Mac OS X older versions, before macOS Mojave 10.14, High Sierra, Sierra 10.12, El Capitan 10.11, etc

      You probably need to install Xcode and Command Line Tools on the Mac first before you can install Homebrew on that Mac OS version.

      So first get command line tools:

      xcode-select --install

      From: https://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/

      Then: older Mac OS versions you must run the proper ruby command with curl –insecure flag to retrieve the Homebrew install script, the proper curl flag must be used because older macOS does not have curl with HTTPS support so it has to be insecure first. But after you install Homebrew, the newer curl is installed with HTTPS support.

      /usr/bin/ruby -e "$(curl --insecure -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

      From: https://docs.brew.sh/Installation

      It is possible you are getting the command wrong too, but it is possible Homebrew is not compatible with your MacOS version though I don’t think that is as likely.

      Good luck! I have Homebrew working fine for me on my Macs with various system software releases, like Mojave, Sierra, El Capitan, Mavericks, etc.

      • Shawal Ahmad says:

        Thanks this work for me…

        My Error:
        {
        remote: Enumerating objects: 37, done.
        remote: Counting objects: 100% (37/37), done.
        remote: Compressing objects: 100% (36/36), done.
        error: RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
        fatal: the remote end hung up unexpectedly
        fatal: early EOF
        fatal: index-pack failed
        Failed during: git fetch origin master:refs/remotes/origin/master –tags –force
        }

        Solution of Problem:

        1. xcode-select –install
        2. /usr/bin/ruby -e “$(curl –insecure -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”

  19. Me says:

    Find stuff via:
    brew search [stuff]
    then
    brew install [stuff]

    There is also a website to search
    http://searchbrew.com

    BTW, thanks for the analytics info!

  20. Coxsone says:

    I guess I was late to the party but recently needed telnet in 10.13. This saved me from having to fire up an XP machine to talk to our HVAC.

    First thing to do is look through what you can install. This is just the base:

    http://formulae.brew.sh/repos/Homebrew/homebrew-core/browse/a

Leave a Reply

 

Shop on Amazon.com and help support OSXDaily!

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Tips & Tricks

News

iPhone / iPad

Mac

Troubleshooting

Shop on Amazon to help support this site