These days at work a collegue came with a question about Homebrew. He had a package installed with Homebrew, and he didn’t want it to be upgraded. He asked me how to prevent it from being upgraded. The answer was quite obvious to me, well as a package manager Homebrew like anyother package manager should be able to prevent a package from being upgraded if you want to do so, but at same time I realize I haven’t seem many people doing this on macOS with Homebrew compared to Linux Super Users.

So here is how you can prevent a package from being upgraded with Homebrew.

First you need to know the version you want to keep, you can do this with:

brew list --versions <package>

The result of this command will show you the stable version for the package and the installed version in your environment.

If the current version is the one you want to keep, you can just pin it with:

brew pin <package>

In some cases you might want to keep a specific version, in this case you can install the version you want with:

brew install <package>@<version>

And then pin it with:

brew pin <package>@<version>

Now if when you run brew upgrade the package will not be upgradedm and if you want to unpin it, you can do it with:

brew unpin <package>

or

brew unpin <package>@<version>

If you don’t know or with to verify if you have any package pinned, you can do it with:

brew list --pinned

This command only list the installed packages you have pinned.

And that’s it, now you know how to prevent a package from being upgraded with Homebrew.

Thank you for reading.