How do I update a formula with Homebrew?
HomebrewFormulaHomebrew Problem Overview
How do I update a formula?
I ran brew update
. Then, running brew outdated
, outputs:
mongodb (1.4.3-x86_64 < 1.6.5-x86_64)
Thus, mongodb
is outdated.
How do I upgrade it? Do I just uninstall and then install?
Homebrew Solutions
Solution 1 - Homebrew
To upgrade just the MongoDB formula, the correct way is
brew install mongodb
If you want to upgrade all outdated formulae, simply do
brew upgrade
Solution 2 - Homebrew
You can update all outdated packages like so:
brew install `brew outdated`
or
brew outdated | xargs brew install
or
brew upgrade
This is from the brew site..
for upgrading individual formula:
brew install formula-name && brew cleanup formula-name
Solution 3 - Homebrew
You will first need to update the local formulas by doing
brew update
and then upgrade the package by doing
brew upgrade formula-name
An example would be if i wanted to upgrade mongodb, i would do something like this, assuming mongodb was already installed :
brew update && brew upgrade mongodb && brew cleanup mongodb
Solution 4 - Homebrew
Well, I just did
brew install mongodb
and followed the instructions that were output to the STDOUT
after it finished installing, and that seems to have worked just fine. I guess it kinda works just like make install
and overwrites (upgrades) a previous install.
Solution 5 - Homebrew
You can't use brew install to upgrade an installed formula. If you want upgrade all of outdated formulas, you can use the command below.
brew outdated | xargs brew upgrade
Solution 6 - Homebrew
I prefer to upgrade all homebrew formulae and homebrew cask formulae.
I added a Bourne shell function to my environment for this one (I load a .bashrc)
function updatebrew() {
set -x;
brew update;
brew cleanup;
brew cask upgrade --greedy
)
}
set -x
for transparency: So that the terminal outputs whatever Homebrew is doing in the background.brew update
to update homebrew formulasbrew cleanup
to remove any change left over after installationsbrew cask upgrade --greedy
will install all casks; both those with versioning information and those without