How to install an older version of a Homebrew package
Installing an older version of some package using Homebrew can be more complex than you expect
I had this problem: I updated Hugo, which is the CMS I use, and one of the versions that were more recent than the one I used introduced a breaking change.
My homepage didn’t list the blog posts any more. I didn’t have the time to figure out why, so I said “I’ll just roll back”.
Now the question became.. “how?”
First, I uninstalled Hugo:
brew unlink hugo
Then I followed the instructions I found on this post. I had to search for the Hugo package formula https://github.com/Homebrew/homebrew-core/search?utf8=%E2%9C%93&q=hugo&type= then I clicked that file (Formula/hugo.rb), and I pressed the History button to see all the previous versions.
Navigated to the 0.53 version I wanted and I clicked the <> button to see the homebrew-core repository at that point in time. Then I opened the Formula/hugo.rb file, and I clicked Raw to get the direct URL to that file.
I then used it as the argument for brew install. For example:
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/5441fa16872c9a56bd5997558df45b808f13285b/Formula/hugo.rb
That’s it.
My next step for solving the problem I had was to uninstall the current version installed, and trying to update one version at a time, so I could isolate the release that introduced the change that was causing me problems.
UPDATE 2024: specifically for Hugo, this didn’t work anymore.
I used npx [email protected] serve instead (see https://cyrusyip.org/en/posts/2023/12/20/run-different-hugo-versions/))
download all my books for free
- javascript handbook
- typescript handbook
- css handbook
- node.js handbook
- astro handbook
- html handbook
- next.js pages router handbook
- alpine.js handbook
- htmx handbook
- react handbook
- sql handbook
- git cheat sheet
- laravel handbook
- express handbook
- swift handbook
- go handbook
- php handbook
- python handbook
- cli handbook
- c handbook
subscribe to my newsletter to get them
Terms: by subscribing to the newsletter you agree the following terms and conditions and privacy policy. The aim of the newsletter is to keep you up to date about new tutorials, new book releases or courses organized by Flavio. If you wish to unsubscribe from the newsletter, you can click the unsubscribe link that's present at the bottom of each email, anytime. I will not communicate/spread/publish or otherwise give away your address. Your email address is the only personal information collected, and it's only collected for the primary purpose of keeping you informed through the newsletter. It's stored in a secure server based in the EU. You can contact Flavio by emailing [email protected]. These terms and conditions are governed by the laws in force in Italy and you unconditionally submit to the jurisdiction of the courts of Italy.