Skip to content

homebrew and linuxbrew formula Notes

chris edited this page May 11, 2021 · 48 revisions

Contents

General homebrew brew & cask usage

To generate a list of files asosciated with a homebrew formula

brew ls -v [NAME_OF_FORMULA]

Homebrew / Linuxbrew provides analytics for monitoring Homebrew usage out of the box

To status if Homebrew analytics is enabled

brew analytics

To disable Homebrew Linuxbrew analytics

brew analytics off

To remove soure tarballs and downloaded .DMGs for homebrew and cask

brew cleanup
brew cask cleanup

...will remove downloaded tarballs and image files stored within the below directory on macOS.

$HOME/Library/Caches/Homebrew

To print the location / directory where homebrew is storing tarballs for downloaded / installed apps.

brew --cache

The above command should print the output of the location of the tarballs, ie.

/home/$USER/.cache/Homebrew

To show outdated formula for homebrew

brew outdated
brew cask outdated --greedy

A lot of formula installed with cask update themeselves, but can also be updated with the --greedy flag.

brew cask upgrade --greedy

To print a list of taps sourced for homebrew usage

brew tap

To print a pretty πŸ’‹ list of installed Homebrew formula and their dependencies in a graphical format

brew deps --tree --installed

To (re)compile a program from source, ie. Vim

brew -v reinstall --build-from-source vim

More information for working with taps

Troubleshooting brew

for reasons unbenounced to me, brew does not install the latest version of Xcode cli tools (CLT) and apple app store or apple softwareupdate cli tools do not install the latest version of the Xcode CLT(s) either. to get around this 1. remove the old version of xcode cli tools as described in the ouput of brew then download the xcode clt dmg, and issue should be resolved. for a complete troubleshooting session, see the homebrew discussion thread i started

Troubleshooting Linuxbrew

Hyper specific to a particular use case of mine, I had an old install of hombrew, and always got a warning about -proto related packages that was super annoying, just for the fact of filling up the screen with warning messages. Apparently linuxbrew has undergone some changes that old installs have to be manually upgraded to stop the warning messages from being printed to STDOUT standard out. learn more

If a brew service has yellow status text then more than likely the service has started but brew does not know what is wrong with the service.

brew services list
brew services stop [MR_FANCY_SERVICE]
brew services start [MR_FANCY_SERVICE]

To post a log to gist.github.com

brew gist-logs [FORMULA_NAME]

To manually view, install and test logs accompanied with a brew formula

cd ~/Library/Logs/Homebrew/[FORMULA]

On a box with linuxbrew install and test logs are located in

~/.cache/Homebrew/Logs/[FORMULA]

Installing Homebrew Linuxbrew

Installing Linuxbrew on Raspbian

  • TODO Complete instructions on installing Linuxbrew on Raspbian

Generating a list of installed packages, ie. formula and casks

brew bundle

To overwrite an existing Brewfile

brew bundle --force dump

Homebrew Cask Installation

To install Homebrew-Cask via Homebrew

brew tap caskroom/cask

Homebrew-Cask has recently been migrated to the Homebrew umbrella on github, ie. Homebrew/homebrew-cask whereas the "main" formula are located at Homebrew/homebrew-core on github.

To install the above mentioned repo

brew tap caskroom/versions

To install a cask from caskroom/versions/hyper-canary

brew cask install hyper-canary

Troubleshooting Homebrew-Cask

GitHub > macOS Security with casks

Setup a multi user brew environment on macOS

Update November 2019

❗️ See this stackoverflow answer for using access control lists on macOS for setting up a multi user brew environment, seems to be the least problematic solution I've come across so far.

  1. Determine the path of the brew prefix, ie. the path that will be used to store files related to working with homebrew
  2. Check that all users on the system who need access to brew are in the admin group
  3. Optional Add a user to the admin group if a user needs access to brew

Will require access / privileges to use the sudo command

  1. Set the brew prefix path to be recursively owned by the admin group
  2. Set the brew prefix path to be recursively writable by all users who are in the admin group
  3. Verify the permissions of the brew prefix
  4. brew

macOS

/usr/bin/env bash
echo $(brew --prefix)
echo $(groups whoami)
sudo dseditgroup -o edit -a $(whoami) -t user admin
sudo chgrp -R admin $(brew --prefix) 
sudo chmod -R g+rwX $(brew --prefix)
ls -lah $(brew --prefix)

When working with a "multi-user" brew environment user_a can not remove / uninstall formula installed by user_b, ie. despite setting a umask for user_a and user_b the Cellar directory will not be group writeable and brew also uses lock files to prevent user_b from removing a formula isntalled by user_a. That said, with the above setup, both users can install and remove their own formula and run programs installed from either user.

Troubleshooting multi user brew environment

Homebrew can create lock files in a Locks directory within the brew --prefix path. These lock files are Formula_name.brewing and can be removed. That said, make sure all users who use brew have read and write access to the Locks directory.

Working with Pythons - 2.x 3.x

Initial Setup

After installing python via homebrew and is properly configured in the PATH

python -m pip install --upgrade setuptools
python -m pip install --upgrade pip

⚠️ When using the --user flag with pip on macOS packages, ie. virtualenv will be placed in `$HOME/Library/Python/[major.minor]/bin/

Homebrew can install concurrent Pythons on the local system.

Homebrew separates its pythons by creating separate binaries, ie. python 2.x is located at

/usr/local/opt/python/libexec/bin/python

and python 3.x is located at

/usr/local/bin/python3

Both pythons use separate pip package managers to manage python dependencies, ie. python 2.x uses

/usr/local/opt/python/libexec/bin/pip

and python 3.x uses

/usr/local/bin/pip3

Python Useful Links

Homebrew documentation - Python

Build time options / parameters

To show build time options for a homebrew formula

brew info [mr_fancy_pants_formula]

brew info weechat

Working with homebrew casks

To search for a brew formula from a cask, ie. kodi

brew search kodi

Output:

brew search kodi                                                                    0 < 14:24:28
==> Searching local taps...
==> Searching taps on GitHub...
caskroom/cask/kodi                                 caskroom/versions/kodi-development
==> Searching blacklisted, migrated and deleted formulae...

Then to install kodi

brew cask install kodi

To edit a formula, make sure the $EDITOR environment variable is set to your favorite text editor, ie. in the fish shell,

set -x EDITOR /path/to/your/favorite/editor

set -x is fish shell specific, and will not with BASH

Ex

set -x EDITOR /home/linuxbrew/.linuxbrew/bin/nvim

Then one can edit the formula of choosing with the below command,

brew edit <name_of_formula.rb>

Ex

brew edit weechat.rb

To list all installed packages with homebrew 🍻

brew list
brew cask list

To get the SHA 256 hash of a file and put the hash in a clipboard on macOS

shasum -a 256 <name_of_file> | awk '{printf $1}' | pbcopy

Working with Homebrew or Linuxbrew formula

Useful Links

TODOs

  • add entries to table of contents for this .md file
  • figure out which binaries belong to which packages, ie. which package installed locate
Clone this wiki locally