krypted.com

Tiny Deathstars of Foulness

Homebrew is a package manager for macOS. You can use Homebrew to install command line packages on a Mac, provided someone has written a formulae, which is a simple Ruby script that walks through the process for installing all the little bits required for a piece of software.

Installing Homebrew is simple. Run the following command which is listed on the Homebrew homepage (not as root):
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
This will install the macOS Command Line Tools from Xcode as well as create the following directories (if they’re not already present):
  • /usr/local/Cellar
  • /usr/local/Homebrew
  • /usr/local/Frameworks
  • /usr/local/opt
  • /usr/local/sbin
  • /usr/local/share/zsh
  • /usr/local/share/zsh/site-functions
  • /usr/local/var
Then the script will move all the required bits from https://github.com/Homebrew/brew to the correct locations. Once done, you can easily install a package if you know the name. For example, I do this on practically every new machine I configure for development:

brew install wget

This one is nice because the dependencies that get installed. And you get the latest versions. Let’s look at the version for wget:

wget -V

Next, let’s use brew to search for something: radius

brew search radius

You’ll see that there’s one item on the local taps: freeradius-server

Let’s install that:

brew install freeradius-server
Now, you’ll find that the bits that make freeradius work are located in /usr/local/Cellar/freeradius-server/3.0.16. If you later need to upgrade that package, use the upgrade verb.

brew upgrade freeradius-server

And finally, to update Homebrew to the latest version, run the update verb:

brew update

March 22nd, 2018

Posted In: bash, Mac OS X

  • epsiblivion

    you man want to mention that you need xcode cli tools installed. here is tim’s script to do it without gui prompts: https://github.com/timsutton/osx-vm-templates/blob/master/scripts/xcode-cli-tools.sh

    • Installing Homebrew will automatically install the CLI tools they (or Xcode) isn’t available. They use the same method that the above script uses, and it would also be better maintained because they’ll be getting bug reports whenever it breaks.

  • JS

    One thing that bugs me is that brew requires to be run as an Administrator user. I typically don’t want to run my everyday chores as one, so I write a little wrapper script:

    #! /bin/sh

    brew=/usr/local/bin/brew
    su=/usr/bin/su
    brewadmin=admin
    if sudo true ; then
    cd /tmp; umask 022
    if [ ! -x ${brew} ] ; then
    installbrew=/tmp/install-brew
    curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install > “${installbrew}”
    chmod 755 “$installbrew”
    sudo ${su} ${brewadmin} -c /tmp/install-brew
    fi
    sudo ${su} ${brewadmin} ${brew} $@
    fi