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:

  1. Start by uninstalling the current version of Hugo using the following command:
brew unlink hugo
  1. 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.

  2. Once you’re in the Formula/hugo.rb file, click on the “History” button to view all the previous versions of the formula.

  3. Find the version you want to install, for example, version 0.53, and click on the <> button to view the homebrew-core repository at that specific point in time.

  4. On the Formula/hugo.rb file page, click on the “Raw” button to get the direct URL to the file.

  5. Finally, use the obtained URL as an argument for the brew install command to install the desired version of Hugo. For example:

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