How to install an older version of a Homebrew package

By

Learn how to install an older version of a Homebrew package with brew version-install, or with brew extract into your own tap when you need more control.

~~~

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

Back then I followed an older workflow: find the Hugo formula on GitHub (Formula/hugo.rb), open the History, pick the commit for the version I wanted (I needed 0.53), open the Raw .rb file, and pass that URL straight to brew install:

brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/5441fa16872c9a56bd5997558df45b808f13285b/Formula/hugo.rb

That no longer works. Homebrew rejects installing a formula from an arbitrary non-checksummed URL. It asks you to use brew extract / a tap instead.

Prefer brew version-install

The current simple path is documented on Homebrew’s Versions page: brew version-install.

It extracts a specific older formula version into your own tap and installs it. Example from the docs:

brew version-install [email protected]

For Hugo, same idea with the version you need:

brew version-install [email protected]

From that point on, you maintain that formula yourself (updates, deprecations, security fixes). Homebrew does not keep every historical version in homebrew/core for you.

When you need more control: brew tap-new + brew extract

If you want the lower-level workflow and to manage the formula file yourself:

brew tap-new yourname/homebrew-old
brew extract --version=0.53 hugo yourname/homebrew-old
brew install yourname/old/[email protected]

brew extract only creates the formula file in your tap. You commit it, push it, and keep it working. Prefer brew version-install when you just want the older build installed.

A simpler path for Hugo specifically

UPDATE 2024 / still true: for Hugo alone, you often don’t need Homebrew at all.

I used npx [email protected] serve instead (see https://cyrusyip.org/en/posts/2023/12/20/run-different-hugo-versions/). That pins the Hugo version per command without fighting the package manager.

Tagged: Mac · All topics

Want me to talk about your product? You can sponsor this site.

~~~

Related posts about mac: