Installing stuff: brew vs. official installer - which one should be used?

Solution 1:

There's a similar question here on Ask Different - What are pros and cons for MacPorts, Fink and Homebrew? - that does a comparison of the different package managers. It's an excellent read and I encourage you to review it.

Should I use Homebrew or the official installer? Why?

The main difference between using Homebrew and using the installer package is the build time dependencies. Homebrew (and MacPorts) does an excellent job of managing all of this. However, with the package, there's no build requirements and the software is ready to go.

Uninstalling is hardly an issue anymore. Homebrew will manage the uninstall process and handle the run time dependencies trimming them if needed. However, with free apps like AppCleaner, thoroughly removing an app is not an issue.

So, bottom line is it comes down to your workflow. If you simply need a utility download the package. If you utilize more than one and there are shared libraries that you want the ability to manage, go with Homebrew.

How can I switch my system from the usage of the /usr/local/bin Node installation to the /usr/local/Cellar one?

You change your path.

Depending on your shell (~/.bash_profile for Bash and ~/.zprofile for Zsh) you merely add the directory of new utility (see ZSH: .zprofile, .zshrc, .zlogin - What goes where? for more info). To ensure that it gets selected before the other (native) application, you put it first in the path variable. For example, the default path is (set by path_helper)

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

In your profile, simply add the line to where your binaries are. Using your example, to add your path:

PATH=/usr/local/Cellar:$PATH

Your new path will have your Cellar directory prepended to the existing one. Because it's prepended (comes before) your existing path, it will look in that directory first. See the Homebrew Documentation for full details. I personally use a combination of MacPorts and "official" installers so I use a different directory structure. YMMV.

Solution 2:

Should I use Homebrew or the official installer? Why?

I'll always prefer a package manager like brew or conda over .pkg files which don't provide uninstallers.

  • One can check what dependencies are going to be installed.
  • Easy cleanup.
  • No need to remember if something came with the standard macOS installation or installed later on.
  • No need to type in root password.

Tools not found on brew and that I build myself are built with CMAKE_INSTALL_PREFIX and installed in ~/Applications. Binaries that I download directly from somewhere are also kept in ~/Applications

Then I add the install path to PATH by ~/.bash_profile.


brew keeps the actual binaries or libraries in /usr/local/Cellar/<package>/<version>/bin and creates an alias in /usr/local/bin or /usr/local/lib or include. And puts the path /usr/local/bin in your PATH variable.

So clearly the official installation is in favour here (maybe because I installed it first? I don't know)

No it's the precedence. In PATH variable, /usr/local/bin is mentioned before /usr/bin by default. (See the install.sh file). So when a binary is found, upcoming locations are not checked.


What you downloaded from the site is a simplified

curl "https://nodejs.org/dist/latest/node-${VERSION:-$(wget -qO- https://nodejs.org/dist/latest/ | sed -nE 's|.*>node-(.*)\.pkg</a>.*|\1|p')}.pkg" \
> "$HOME/Downloads/node-latest.pkg" \
&& sudo installer -store -pkg "$HOME/Downloads/node-latest.pkg" -target "/"

I'd guess that node is installed in /usr/bin.


So to clean things up,

  • Run brew uninstall node
  • Get the xz file from https://nodejs.org/dist/latest/ and check its contents.
  • One by one, find all the folders and files like README and changelog that match the xz you downloaded, and delete them. Most probably, they can be found at /usr/bin, /usr/local/bin. What would help here is using finder and sorting by "Date Added".
  • brew install node.

How can I switch my system from the usage of the /usr/local/bin Node installation to the /usr/local/Cellar one?

After you've done the steps above, and the brew installation is correct, i.e. echo $PATH contains /usr/local/bin, you don't have to do anything extra.

Solution 3:

If you're planning to install a lot of stuff, then you may find a package manager more useful; if there's only a handful of things that you need to install, which have their own installers and for which updating is easy, then installing something like HomeBrew may just add another layer of complexity.

There are also security implications to putting all your eggs in one basket. https://medium.com/@vesirin/how-i-gained-commit-access-to-homebrew-in-30-minutes-2ae314df03ab

Solution 4:

Regarding your first question Should I use Homebrew or the official installer? I feel the need to add a downside of using Homebrew which I didn't see here or in the other question: long term compatibility.

Take for example El Capitan, which is installed on Macs that cannot be upgraded further. While those Macs still can function fine, Homebrew (as Apple) has dropped support for this OS version. Now if you try to brew install something on El Capitan it might work, it might fail, or it might start a lengthy compilation procedure and then fail.

I found it's not worth trying out this process every time, so now on the old machine I install everything with the official installer.