Homebrew

Homebrew is well known and should be considered a “must have”, so much so that we have already mentioned it several times on this digital notebook but only incidentally to describe some commands.

Homebrew is an open-source package manager written in Ruby (on GitHub) that allows the installation of packages missing from Apple’s operating system (or Linux).

Install Homebrew

Homebrew installation is described on the official site home page, and run it by launching the Terminal app and typing the following command:

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

As indicated on the page about installing Homebrew, you may need to install Xcode, or Command Line Tools (CLT) for Xcode via the command from the Terminal

xcode-select --install

The installation path changes depending on the processor that is on the Apple machine specifically:

  • Intel Mac, Homebrew installs to the following path:

/usr/local

  • Mac Silicon (M1-M2) in the following path:

/opt/homebrew

On Silicon Macs, an additional step is required because the /opt/homebrew folder is not part of the default $PATH. Therefore, the following message should be present at the end of the installation.

- Add Homebrew to your PATH in ~/.zprofile:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

Therefore, it will be sufficient to open the Terminal app and type the following command:

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

That will add the string eval "$(/opt/homebrew/bin/brew shellenv)" to the file ~/.zprofile. To verify that this was successful, from the Terminal app, you can open the file .zprofile with an editor as in the following command:

nano ~/.zprofile

If everything was successful, you would see the string eval "$(/opt/homebrew/bin/brew shellenv)"

If you want to verify the correct installation of Homebrew, you can type the following command from the Terminal app:

brew doctor

If everything was successful, you would see the following message

Your system is ready to brew.

Tip for Analytics

As stated on the official website

Homebrew gathers anonymous aggregate user behaviour analytics using Google Analytics.

Therefore, after installation, we suggest disabling “Analytics” using the following command:

brew analytics off

You can verify by the following command:

brew analytics state

And you will see the following message:

Analytics are disabled.

Below is the video that plays the installation of Homebrew and the execution of some commands described so far.

Install packages

Once Homebrew has been installed, when it wants to install a package, simply launch the Terminal app and type

brew install <nomepacchetto>

To find out which packages have been installed, run the following command

brew list

Sometimes installed packages have so-called “dependencies” (basically other packages needed for proper functioning the application you install). With the following command, you can see all the installed packages and their dependencies:

brew deps --tree --installed

If you want to see the dependencies of a specific installation, you will have to type the following command

brew deps --tree --installed <nomepacchetto>

The commands we prefer

There are some commands that need to be used most frequently, and it takes work to remember them along with any parameters. Therefore, our selection aims to indicate those commands we usually use most frequently.

  • Update Homebrew:
brew update
  • Upgrade packages:
brew upgrade
  • Execute the above commands together
brew update && brew upgrade
  • Deleting a package:
brew remove <nomepacchetto>
  • List of packages that have a new version:
brew outdated
  • Remove all remaining unused dependencies:
brew autoremove
  • Removes obsolete files and outdated downloads (older than 120 days) for all formulas all downloads (the -s option clears the cache, including downloads of newer versions):
brew cleanup -s

To make sure that all packages have been removed, you can run the following command (the --dry-run option does not perform the deletion but only shows what will be deleted)

brew cleanup --prune=all --dry-run

With the following command, you will have the actual elimination

brew cleanup --prune=all
  • Install applications (applications will be found in Applications).
brew install <nomeapp> --cask
  • Remove applications
brew remove <nomeapp> --cask

We use another powerful resource which is Texexpander, and all the commands indicated can also be defined as “snippets” and called up by typing the label we have assigned.


If this resource was helpful, you could contribute by

Buy me a coffee

Or donate via

Liberapay


Follow us on Mastodon

Stay tuned!