This is a guide on how to use brew pin command, aka how Stick with a specific version of a package in homebrew.
Lately I had to stop updating php since i rely on xdebug for debugging and xdebug (the debugger for php) still doesn’t really support the latest versions of php (hopefully it will get updated soon).
Usually when you run brew update it is going to update all the packages for which a newer version has been released, the only other command line argument you can give is to dforce update a single package by running `brew upgrade packageName’. This was not a doable solution sinc e i’m using brew to manage most of my Mac OS Developer Tools and Utilities. Luckily you can also tell homebrew to stop updating a particular package using pin until you come back and unpin it.
Pin a package
To pin a package run
brew pin packageName. For php I ran:
brew pin php
brew pin firstname.lastname@example.org
Unpin a package
Whenever you want to unlock it just unpin it:
brew unpin php
brew unpin email@example.com
If you now execute brew upgrade bot php and php7.2 will be updated to the latest version.
Bonus: Brew Cleanup
As a bonus try using
brew cleanup to delete unused (and old) versions of your installed packages to save disk space. If you’ve never run it before you are going to save a lot of space (on an old Mac I saved almost 2GB).