How to Install an Older Version of a Homebrew Package
Installing an older version of a package using Homebrew can sometimes be more complicated than expected. In this blog post, I will walk you through the process of installing an older version of a package using Homebrew, using Hugo as an example.
Recently, I encountered an issue where an update to Hugo, the CMS I use, introduced a breaking change that caused my homepage to no longer list blog posts. Instead of spending time investigating the root cause, I decided to roll back to a previous version.
Here’s how I accomplished that:
Start by uninstalling the current version of Hugo using the following command:
1
brew unlink hugo
Next, you’ll need to find the previous version of the Hugo package. To do this, search for the Hugo package formula on the Homebrew Core repository and click on the
Formula/hugo.rb
file.Once you’re in the
Formula/hugo.rb
file, click on the “History” button to view all the previous versions of the formula.Find the version you want to install, for example, version 0.53, and click on the
<>
button to view thehomebrew-core
repository at that specific point in time.On the
Formula/hugo.rb
file page, click on the “Raw” button to get the direct URL to the file.Finally, use the obtained URL as an argument for the
brew install
command to install the desired version of Hugo. For example:1
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/5441fa16872c9a56bd5997558df45b808f13285b/Formula/hugo.rb
That’s it! By following these steps, you can install an older version of a Homebrew package such as Hugo. In my case, this helped me isolate the problematic release and update one version at a time to identify the breaking change causing the issue.
Tags: Homebrew, package installation, Hugo, rolling back, breaking change, version control