All notes
Homebrew

Quick start

It is a package manager for macOS. brew website.


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


# https://github.com/caskroom/homebrew-cask/issues/5328
# If there is 404 error for downloading packages, it may be caused by an old version of Homebrew Cask.
brew update && brew cleanup && brew cask cleanup


# To see all files in a package:
brew ls $package
brew info $package
# To find the package for a file, look at the file like this:
ls -l /usr/local/bin/whatever

# Where does stuff get downloaded?
brew --cache
# /Users/me/Library/Caches/Homebrew

brew search $AppName

########## Update related

# Update the formulae and Homebrew itself
brew update

# Find out what is outdated
brew outdated

# Upgrade everything with:
brew upgrade
# Upgrade a specific formula with:
brew upgrade $FORMULA

# Stop something from being updated/upgraded:
brew pin $FORMULA
# Allow that formulae to update again:
brew unpin $FORMULA

########## Clean up old versions

# Dry-run
brew cleanup -n
# Really run
brew cleanup

########## Troubleshooting

brew update #
brew update # (twice)
brew doctor

########## Other

# Quickly remove something from /usr/local
brew unlink $FORMULA
# Readd
brew link $FORMULA

# Activate a previously installed version of a formula
brew info $FORMULA
brew switch $FORMULA $VERSION

# Install into Homebrew without formulae
./configure --prefix=/usr/local/Cellar/foo/1.2 && make && make install && brew link foo

Commands

services


brew info mariadb

# To have launchd start mariadb now and restart at login:
sudo brew services start mariadb

tap



# Will add https://github.com/ruffjs/homebrew-ruff to brew repo.
brew tap ruffjs/ruff
brew install ruff

# You can also install via URL:
brew install https://raw.githubusercontent.com/ruffjs/homebrew-ruff/master/<formula>.rb

cask


brew cask install vagrant
brew cask install chefdk # Downloading https://packages.chef.io/stable/mac_os_x/10.12/chefdk-2.0.28-1.dmg

FAQ

Another version is already linked

Another version is already linked: /usr/local/Cellar/libyaml/0.1.4

Try brew upgrade libyaml; brew link libyaml. See github.com: homebrew.

/usr/local permissions

jamf.com mentioned about how homebrew setting /usr/local permissions affect other apps. Solution:


sudo chown -R $(whoami):admin /usr/local
# This will fix it
sudo chown -R root:wheel /usr/local/jamf

And it seems not possible for homebrew to change its installation destination, see SuperUser: change install location and prefix. Simply put, the /usr/local/ is the default prefix for most packages.

Solution

wcfNote: one solution is to add me - the user - to wheel group, so that "me" and write in /usr/local/bin:


# https://superuser.com/questions/60150/is-there-a-usermod-equivalent-in-terminal-for-os-x-10-6-1
sudo dscl . append /Groups/wheel GroupMembership me
If there is any problem, e.g. pcre-config says no permission:

chown `whoami` pcre-config

Install python-pip

SO: install pip on MacOS.


# Just install the pip.
sudo easy_install pip