34

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 ?

Pierre-Adrien
  • 2,607
  • 30
  • 28
  • you can install specific version of packages : more info on http://stackoverflow.com/questions/3987683/homebrew-install-specific-version-of-formula – DarkMukke Sep 26 '14 at 09:40
  • Yes I know that (and this SO question came in handy this morning when I was looking for a way to downgrade). But I was wondering if a solution existed to prevent the upgrade of a specific package. – Pierre-Adrien Sep 26 '14 at 12:18
  • Possible duplicate of [Ignore formula on brew upgrade](https://stackoverflow.com/questions/10093918/ignore-formula-on-brew-upgrade) – Flimm Aug 16 '19 at 09:25

3 Answers3

48

brew pin someformula.

There is also a lua51 formula now.

Tim Smith
  • 5,827
  • 1
  • 23
  • 31
  • @Oderdra this is a valid answer. Although I´m struggling to find a link which documents `brew pin` it is there and does solve the OP´s issue. – max Sep 27 '14 at 17:53
  • 1
    from the output of `man brew`: `Pin the specified formulae, preventing them from being upgraded when issuing the brew upgrade command without arguments. See also unpin.` – Zev Eisenberg Sep 27 '14 at 18:15
  • @Odedra it does provide an accurate answer to my question. But I'm struggling as well to find some documentation, apart from the man. One should never forget the man files ! – Pierre-Adrien Sep 28 '14 at 23:04
  • Yea, I guess I should've looked a bit more of the details of ``brew pin`` before running ``brew upgrade $(brew outdated)``, because that *does* include an argument, and so the pinning is not enforced. – brki Mar 31 '16 at 12:25
1

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`
Br.Bill
  • 553
  • 3
  • 11
0

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
eli chan
  • 21
  • 3