Installing Old Homebrew Formulas
Over the past several years, Homebrew has made it continually difficult to install an outdated formula. I'm not quite sure why, but it's been a struggle for developers for the past 7+ years.
However, there is a workaround (however it's not straight-forward). For this example, I'll use
- Note the version you currently have installed:
$ ruby-build --version ruby-build 20210825
- If the version you have installed is later than the one you want installed, try this:
$ brew install ruby-build@20210707 Warning: No available formula or cask with the name "ruby-build@20210707". Did you mean ruby-build? ==> Searching for similarly named formulae... This similarly named formula was found: ruby-build ✔ To install it, run: brew install ruby-build ✔ ==> Searching for a previously deleted formula (in the last month)... Error: No previously deleted formula found. ==> Searching taps on GitHub... Error: No formulae found in taps.
- If that doesn't work (such as my example above), navigate to https://github.com/Homebrew/homebrew-core/find/master
- Search for the formula you'd like to install:
Historyto see the file's commit history:
- Find the most recent commit that describes the formula version you want, and click the commit:
- GitHub will highlight the file in that commit, and click the three dots on the upper right corner of the file, and then click
Rawto view the entire file in its raw form:
- On your terminal, create the file
FORMULA.rb, and copy-paste the contents of the file from GitHub to the file on your machine:
$ touch ~/ruby-build.rb $ vim ~/ruby-build.rb # Copy-paste the contents from the GitHub file here # Press :wq to quit when you're done
- Now install the formula from that file directly (you may need to unlink existing formula(s)):
$ brew install ~/ruby-build.rb Error: Failed to load cask: /Users/emmasax/ruby-build.rb Cask 'ruby-build' is unreadable: wrong constant name #<Class:0x00007fb7811c01c0> Warning: Treating /Users/emmasax/ruby-build.rb as a formula. Error: ruby-build 20210825 is already installed To install 20210707, first run: brew unlink ruby-build $ brew unlink ruby-build Unlinking /usr/local/Cellar/ruby-build/20210825... 4 symlinks removed. $ brew install ~/ruby-build.rb Error: Failed to load cask: /Users/emmasax/ruby-build.rb Cask 'ruby-build' is unreadable: wrong constant name #<Class:0x00007fd9a8bb7ba8> Warning: Treating /Users/emmasax/ruby-build.rb as a formula. ==> Downloading https://ghcr.io/v2/homebrew/core/ruby-build/manifests/20210707 . . . ==> Summary 🍺 /usr/local/Cellar/ruby-build/20210707: 536 files, 266.5KB Removing: /Users/emmasax/Library/Caches/Homebrew/ruby-build--20210707... (55KB) $ ruby-build --version ruby-build 20210707
Voilá! And, we can see all versions of the formula on our machine:
$ ls /usr/local/Cellar/ruby-build/ 20210707 20210825
Unfortunately, doing any sort of
brew upgrade or
brew unlink FORMULA && brew link FORMULA will get you back to where you started. You can try to implement something like this, but I haven't tested any of that personally.
Best of luck brewing!