Installing packages and applications with Homebrew

-

You may know the Homebrew; “The Missing Package Manager for MacOS (or Linux)”, like it calls itself. Homebrew is a handy package manager you can use to install various packages that are not standard for MacOS. But did you also know you can install applications with it? This article will give a short introduction to using this tool.

The only thing you need to do is to have Homebrew installed. You can do this with a /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)” inside a terminal. More information on this can be found on their website.

Installing packages

When, for instance, you need to have NodeJS installed, you can use Homebrew to install it with a simple brew install node inside a terminal to install the latest version or brew install node@10 to install it at the latest version 10. You can also install multiple versions, like the two NodeJS examples just mentioned and switch between them with brew unlink node and brew link node@10.

All packages will be installed inside the folder usr/local/Cellar and symlinked to the Library to not mess with your default system settings. When uninstalling a package with brew uninstall your system is back in original state.

Installing applications

If you know Homebrew you probably know all this already. But did you also know it can install applications to the applications folder as well? You can do this with brew cask.

This is as simple as installing a package. And if you have Homebrew installed you are already fully set up.
You can install, for instance, the text editor “Atom” with a simple brew cask install atom in a terminal. And then the app is installed in the Application folder. Simple as that! It will give you something that looks like this:

markdejong@Marks-MBP ~ % brew cask install atom
==> Downloading https://github.com/atom/atom/releases/download/v1.44.0/atom-mac.zip
==> Downloading from https://github-production-release-asset-2e65be.s3.amazonaws.com/3228505/b9a72600-4ccc-11ea-8f43-51eb905c3e0a?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20200219%2Fus-east-1%2Fs3%2Faws4
######################################################################## 100.0%
==> Verifying SHA-256 checksum for Cask 'atom'.
==> Installing Cask atom
==> Moving App 'Atom.app' to '/Applications/Atom.app'.
==> Linking Binary 'apm' to '/usr/local/bin/apm'.
==> Linking Binary 'atom.sh' to '/usr/local/bin/atom'.
🍺  atom was successfully installed!
markdejong@Marks-MBP ~ %

Updating applications

Some apps have auto upgrades built in the app. For others you can run brew cask upgrade to update all apps installed with Homebrew to the latest version.

Uninstalling applications

You can also uninstall an application installed with Homebrew, like Atom, again with brew cask uninstall atom to fully remove it from your system.

markdejong@Marks-MBP ~ % brew cask uninstall atom
==> Uninstalling Cask atom
==> Backing App 'Atom.app' up to '/usr/local/Caskroom/atom/1.44.0/Atom.app'.
==> Removing App '/Applications/Atom.app'.
==> Unlinking Binary '/usr/local/bin/apm'.
==> Unlinking Binary '/usr/local/bin/atom'.
==> Purging files for version 1.44.0 of Cask atom
markdejong@Marks-MBP ~ %

Automate all the things!

As this is a terminal only thing, you could also create a shell script to install Homebrew and install all your favorite non-app store apps and packages automatically for when you need to reinstall your computer.

A start for this could be:

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

# installing packages
brew install nodejs
brew install mongodb
brew install openssl
# ...

# installing applications
brew install postman
brew install google-chrome
brew install visual-studio-code
# ...

A full list of all available applications and packages to install with Homebrew can be found on their website here.