Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
Installation
macOS
By default,
Homebrew is installed to the location /opt/homebrew
.
You can add the command brew
into $PATH
by adding the following configuration into your shell configuration
(e.g., .bashrc
for bash)
.
eval "$(/opt/homebrew/bin/brew shellenv)"
Linux
https://github.com/Homebrew/install
sh -c "$(curl --proxy http://your.proxy.servder:port -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
The installation script installs Homebrew to /home/linuxbrew/.linuxbrew using sudo if possible and in your home directory at ~/.linuxbrew otherwise. Homebrew does not use sudo after installation. Using /home/linuxbrew/.linuxbrew allows the use of more binary packages (bottles) than installing in your personal home directory.
Follow the instructions below if you have to install Linuxbrew using a proxy.
- Configure the environment variables
http_proxy
andhttps_proxy
.Bash export http_proxy=http://your.proxy.server:port export https_proxy=http://your.proxy.server:port
- Configure proxy for Git (as Linuxbrew rely on Git to work) following instructions in Use Git Behind a Proxy.
You can export environment variables for Linuxbrew using the following command
assuming Linuxbrew is installed to /home/linuxbrew/.linuxbrew
.
/home/linuxbrew/.linuxbrew/bin/brew shellenv >> .bash_profile
Or use the following command if Linuxbrew is installed to ~/.linuxbrew
.
~/.linuxbrew/bin/brew shellenv >> .bash_profile
Tips and Traps
-
All Homebrew formulas are listed at https://formulae.brew.sh/formula/. You can search on the site for available formulas.
-
Linuxbrew/brew has been merged into Homebrew/brew. For more please refer to this issue. Linuxbrew is a good tool to install Linux packages in environments which you do not have sudo permission.
-
You might encounter link problems when you use the
brew
command to install packages on Mac. A possible way to fix the issue is to manually configure thePATH
environemnt variable. Or a quick and dirty way to resolve the problem is to link the executable file into$HOME/bin
. -
You can install a specific version of a package using the
@
symbol. For example, the command below installs node 8.brew install node@8
All available versions of a package (say, node) can be listed using the following command.
brew search node@
If there are multiple version of a package (say, node) installed, you can set the default version of the package to use using the command below.
brew switch node 10.15.0
-
Uninstall a package, say,
telnet
.brew uninstall telnet # or brew remove telnet
-
Do not install python using brew as you will end up with 2 copies of python
-
better to use MacVim instead of Vim.
brew install macvim
The command for MacVim is
mvim
. For convenience, you can link it to$HOME/bin/vim
. -
No readlink on Mac. Use
greadlink
instead. You have install the packagecoreutils
in order to usegreadlink
.brew install coreutils
Example Commands
brew install
brew uninstall
brew link
brew unlink
brew search
brew list
brew list | xargs brew uninstall
brew search python@3.6
brew ls --versions node
-
Install gcc/g++.
brew install gcc
-
Install LLVM and clang.
brew install llvm
References
Why linking keg-only formulae requires –force option in homebrew?
https://apple.stackexchange.com/questions/329187/homebrew-rollback-from-python-3-7-to-python-3-6-5-x
https://stackoverflow.com/questions/3987683/homebrew-install-specific-version-of-formula
http://osxdaily.com/2018/06/13/how-install-update-python-3x-mac/