Homebrew | Getting started
Installation
Install on macOS
Install
An important dependency before Homebrew can work is the Command Line Tools for Xcode. These include compilers that will allow you to build things from source.
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Setup environment
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bash_profile
Check installation
brew doctor
Using Homebrew
To install a package (or Formula in Homebrew vocabulary) simply type:
brew install <formula>
Update
To update Homebrew’s directory of formula, run:
brew update
To see if any of your packages need to be updated:
brew outdated
To update a package:
brew upgrade <formula>
Homebrew keeps older versions of packages installed, in case you want to roll back. That rarely is necessary, so you can do some cleanup to get rid of those old versions:
brew cleanup
To see what you have installed (with their version numbers):
brew list --versions
Homebrew Cask
Let’s see if we can get the elegance, simplicity, and speed of Homebrew for the installation and management of GUI Mac applications such as Google Chrome and Adium.
brew cask install google-chrome
Configure brew on macOS
If you want to use tools such as ruby or gem, you can configure brew to use this tools without the need of superuser permissions: Use environment variable:
export RBENV_ROOT="$(brew --prefix rbenv)" export GEM_HOME="$(brew --prefix)/opt/gems" export GEM_PATH="$(brew --prefix)/opt/gems"
Look here
Installation of a Package
Install a specific ruby version
brew update brew install rbenv brew install ruby-build
Once you have rbenv and ruby-build installed, you can run the following command to get Ruby 2.3.0 installed.
rbenv install 2.3.0
Now if you’d like to use 2.3.0 by default, you can run the following command:
rbenv global 2.3.0
Finally, add this to your .bashrc
eval "$(rbenv init -)"