44

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,836
  • 29
  • 30
  • 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
  • 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

58

brew pin someformula.

There is also a lua51 formula now.

Tim Smith
  • 6,127
  • 1
  • 26
  • 32
  • @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
3

brew pin formula works well, but it's not currently 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
  • 637
  • 5
  • 12
  • Since we can't currently pin casks, this seems like the only one useable when casks are your pinning target. Do watch out, though - if you typo the 'cask-to-skip', and the typo isn't in the list, it won't skip any... :) – Jesse Adelman Apr 17 '23 at 14:36
  • Agree, @JesseAdelman. Luckily I'm using a script so I won't mistype it – Br.Bill Apr 28 '23 at 00:09
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