4

I hope there is a command equivalent for casks that works to ignore updates on main line packages.

brew upgrade --ignore <FORMULA>

This Stack Overflow question from 2014 has multiple answers that mention brew pin as a solution, but that feature does not work for casks:

How is it possible to ignore a formula by name while upgrading packages in Homebrew with brew upgrade?

5 Answers 5

2

Workaround

You can use buo/homebrew-cask-ugrade, which is a third-party tool with extra cask upgrade features, including pin.

brew tap buo/cask-upgrade    # Install `brew-cask-upgrade`
brew cu pin <CASK_NAME>      # Pin the cask you want

Reason for workaround

It looks like the Homebrew maintainer will not allow pinning of casks, because many casks auto-update, which Homebrew technically can't prevent from happening.

From a comment on homebrew/homebrew-cask: Allow pinning casks #49127:

A huge chunk of casks auto-update and we can’t stop that. So pin would at best be inconsistent and not work in a lot of cases.

4
  • 1
    Yes, this is great... but what about casks that doesn't auto-upgrade AND you absolutely DO NOT want to upgrade them (I think of eclipse-java... when using brew upgrade it breaks your install).
    – maxxyme
    Mar 11 at 20:52
  • I'm not sure, but if you want to fix that issue specifically, I'd switch to IntelliJ IDEA. It's much better than eclipse and doesn't have this issue.
    – Neil
    Mar 12 at 5:26
  • Honestly, I tried a few times IntelliJ over the recent years, and I hate it; to me, it's no better than Eclipse, I found it's just another over-complicated bloated IDE... and as I'm used to Eclipse for more than 15 years now, I don't find any reason to change. Or maybe for VS Code... ah ah!!! but we're OT here...
    – maxxyme
    Mar 14 at 11:28
  • Perfect solution! Thanks, worked like a charm to avoid these minor upgrades to libreoffice that took ages for a tool I don't use much. Jul 22 at 22:23
2

If you are willing to write some BASH code, this can be done in a one liner using brew list and grep --invert-match:

brew upgrade $(brew list | grep --invert-match <FORMULA>)

Essentially, we just filter the list of packages installed by brew and filter the one called <FORMULA> using grep's inverted matching.

Tested with brew 3.4.3 on GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin20).

1
  • 1
    Just used this, great answer. To be precise I use it for casks, but it would work for formulae just as well. I read an environment variable from a list of casks to be ignored like this: BREW_CASK_IGNORELIST=$(awk '{print $1}' .brew-upgrade-cask-ignorelist | paste -s -d"|" - |sed "s/\|/\\\|/g"); followed by brew upgrade --cask --greedy --force $(brew list --cask | grep --invert-match --regexp $BREW_CASK_IGNORELIST). Mar 27 at 21:19
1

Does brew know or care that internet thinks that pin is removed? :-)

My brew (3.3.12, last commit 2022-01-26) does know nothing about it. From man brew

pin installed_formula [...]
       Pin the specified formula, preventing them from being upgraded when issuing the brew upgrade
       formula command. See also unpin.

upgrade [options] [outdated_formula|outdated_cask ...]
       Upgrade outdated casks and outdated, unpinned formulae using the same options they were
       originally installed with, plus any appended brew formula options. If cask or formula are
       specified, upgrade only the given cask or formula kegs (unless they are pinned; see pin, unpin).

Documentation seems to be in par with reality as I was able to pin, output pinned list and unpin:

+ > brew pin fzf
+ > brew list --pinned
fzf
+ > brew unpin fzf
+ > brew list --pinned
+ >

Whether pin is what you want or need is another story, but rumors that pin is removed are greatly exaggerated.

1
  • Sorry, I was mistaken when I said "removed". I had meant that pin doesn't work for casks, since there is no --cask option and casks aren't mentioned in pin's --help or the man page.
    – Neil
    Feb 4 at 7:10
1

I found another workaround that will also somewhat work with brew upgrade by simply removing the Cask file from /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask/Casks.

After removing the file, brew no longer checks the cask for updates and therefore does not even list it in brew upgrade anymore. Keep in mind that this will definitely break all other operations with this cask.

My issue was that I had to pin the version of a JDK as brew would try to upgrade it to a newer version which was not available in production yet. Therefore I deleted the /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask/Casks/temurin.rb file.

1
  • Genius answer! Works better than modifying the cask file with a different version number, because that gets clobbered every global update.
    – Neil
    Jul 19 at 15:15
-1

A seemingly safer variation of Max's answer is to delete the relevant folders in /opt/homebrew/Caskroom/.

This seems to cause brew to forget it installed them (e.g. they no longer appear in brew list, but without messing with brew's library internals.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .