How do I update a formula with Homebrew? - homebrew

How do I update a formula?
I ran brew update. However, mongodb is still outdated according to brew outdated:
mongodb (1.4.3-x86_64 < 1.6.5-x86_64)

First, update brew's internal list of formulae to the latest:
brew update
To upgrade only the mongodb formula, use install:
brew install mongodb
To upgrade all outdated formulae:
brew upgrade

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

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

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.

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

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 formulas
brew cleanup to remove any change left over after installations
brew cask upgrade --greedy will install all casks; both those with versioning information and those without

Related

brew install rbenv Error: rbenv-rbenv already installed To install this version, first `brew unlink rbenv`

I am trying to install rbenv on OS X by following instruction from site link - setup ruby on macbook
when I try brew install rbenv I get below error
Error: rbenv-rbenv already installed To install this version, first 'brew unlink rbenv'
Here is the output from brew doctor
brew doctor
Your system is ready to brew.
I tried brew unlink rbenv on which fails with message Error: No such keg: /usr/local/Cellar/rbenv
Please suggest how this can be solved.
I have tried all solutions as listed below
brew update
brew prune
brew link rbenv
nothing really works
This, I was able to solve by thrashing all the junk files and folders related to rbenv still existing in the system; as brew link rbenv wasn't working
Use command below to find any rbenv files/folder still existing in the system.
sudo find /user/ -name "*rbenv*"
most of the issues could be because /usr/local/opt may still have folders related to rbenv
then carefully remove any listed files/folder using command
sudo rm -r <folder-listed-in-result-of-above-command>
then try brew install rbenv, follow any output from this command (which may suggest brew unlink rbenv && brew link rbenv) and you should be good to go.
I do not recommend file/folder thrashing this way as it could be risky however, to be frank, this is only what worked for me.

Why can't brew find a specific known formula?

I'm trying to install bazel on my mac (10.11.5).
I can see that it is available through brew:
http://braumeister.org/formula/bazel
But when I run "brew install bazel", I get this:
Error: No available formula for bazel
Searching formulae...
Searching taps...
Why is this?
In my case, Homebrew was already up-to-date after running brew update and I still received the same error messages as the OP when trying to install xdebug:
$ brew update
Already up-to-date.
$ brew install php70-xdebug
Error: No available formula with the name "php70-xdebug"
Using Mark's suggestion from the comments on OP solved the problem:
$ brew search xdebug
homebrew/php/xdebug-osx homebrew/php/php70-xdebug
So now, running $ brew install homebrew/php/php70-xdebug, Homebrew found and installed the package.
You should update your brews, because it is indeed available. Run
brew update
brew install bazel
and then it should work.

How to uninstall Homebrew Cask

I installed Homebrew Cask for kicks as described at http://caskroom.io/. It boils down to the following command:
$ brew install caskroom/cask/brew-cask
$ brew tap caskroom/versions
Homebrew Cask installed and everything was fine. Then I uninstalled Homebrew Cask like so:
$ brew untap caskroom/versions
$ brew uninstall brew-cask
Here are the current taps:
$ brew tap
homebrew/versions
Yet I see stuff from Cask when searching for items that wouldn't be part of Homebrew itself (like Graphical programs, aText, Fantastical etc.):
$ brew search atext
Caskroom/cask/atext
Though it doesn't install (as expected):
$ brew install atext
Error: No available formula for atext
Searching formulae...
Searching taps...
Caskroom/cask/atext
So the question is why does brew search Caskroom/cask and how do I get rid of it (I don't want Homebrew telling me it has aText, for example, when it can't install it)?
I am running Mac OS X Yosemite.
For the current version of Brew:
$ brew uninstall --cask yed
For older versions of Brew:
$ brew cask uninstall yed
the result:
==> Removing App symlink: '/Users/user/Applications/yEd.app'
As of Homebrew version 0.9.5, it appears that brew search will find items in Caskroom/cask/ without actually having Homebrew Cask installed. You can also install them, but this will actually install brew-cask as a dependency along the way.
Try:
brew install Caskroom/cask/atext
Command the terminal to "untap" at the prompt [MacOS Catalina 10.15.2]
Run
brew untap homebrew/cask-fonts
Expected output
Untapping homebrew/cask-fonts...
Untapped 1571 casks (1,713 files, 11.4MB)

Homebrew updates and app self updates

How does homebrew/cask's updates work if the app auto updates itself.
Example: Chrome or Firefox
These two apps auto update themselves.
But what happens when you run a brew update?
Does it detect that it is already updated or does it check an internal list of apps it installed (misses that it is already updated) and reupdates the app>
brew cask upgrade is possible as of version 1.3.9
The Homebrew Cask repository is technically a Homebrew Tap.
This means:
It will pull down the latest Casks every time you issue the Homebrew command brew update
You can check for outdated Casks with brew cask outdated and install the outdated Casks with brew cask upgrade
Most importantly for this question, applications that update themselves include auto_updates true. This means that these casks are ignored by brew cask outdated and brew cask upgrade. This can be overridden by adding --greedy to the command.
See the Firefox cask as an example:
url "https://download-installer.cdn.mozilla.net/pub/firefox/releases/#{version}/mac/#{language}/Firefox%20#{version}.dmg"
appcast 'https://www.macupdater.net/cgi-bin/check_urls/check_url_redirect.cgi?url=https://download.mozilla.org/%3Fproduct=firefox-latest-ssl%26os=osx'
name 'Mozilla Firefox'
homepage 'https://www.mozilla.org/firefox/'
auto_updates true
Further reference is here.
Homebrew doesn't follow a new version of cask apps automatically, and you can leave such apps to their own auto updates as Homebrew intends to leave it to their own upgrade systems and e.g.
brew upgrade google-chrome
does nothing even when google-chrome has got a new update.
N.B. Now with Homebrew 2.5.5, brew cask was deprecated and integrated to the normal brew.
If you want to do for cask explicitly, you may want --cask
brew upgrade --cask google-chrome
but all the same basically.
Should you want to follow the latest version on your Homebrew proper, you can run such a command as
brew upgrade --greedy google-chrome
Also you can check a diff between the latest and your local with
brew upgrade --greedy --dry-run google-chrome
This way however is mostly for cask apps without their own upgrade systems and you don't need these commands for those with the upgrade systems as long as you're not concerned about your version numbers on Homebrew.
No. There is no brew cask upgrade.

How to prevent homebrew from upgrading a package?

I'm wondering if there's any means to prevent Homebrew from upgrading a particular package ? Yesterday I went for a brew upgrade which updated the lua package from 5.1 to 5.2. It broke one of the projects I'm working on those days so I had to downgrade the lua package today when I noticed it.
I'd like this not to happen again, and I guess Homebrew must provide this kind of feature, but I didn't find anything about it in the documentation. Do you have any clue ?
brew pin someformula.
There is also a lua51 formula now.
brew pin formula works well, but it's not possible to pin casks.
I need to prevent upgrade of a particular cask, so I use a filter to ignore that cask when upgrading:
brew update
brew upgrade --cask `brew outdated --cask | awk '{print $1}' | grep -v cask-to-skip`
To complete the story, for my case using opencv as an example, it means that
brew -v edit opencv3
brew -v fetch --deps opencv3
brew -v install --build-from-source opencv3
brew pin opencv3

Resources