Skip to content

Instantly share code, notes, and snippets.

@lordlycastle
Created June 23, 2020 10:56
Show Gist options
  • Save lordlycastle/78d4721ee3b7f2a78df9e325e477c1d6 to your computer and use it in GitHub Desktop.
Save lordlycastle/78d4721ee3b7f2a78df9e325e477c1d6 to your computer and use it in GitHub Desktop.

Downgrade any Homebrew package easily

Posted on March 21, 2019 by Dae

I'll use Tesseract as an example, but the same logic can be applied to any other Homebrew package.

Backstory: I ran brew upgrade which upgraded Tesseract on my computer from version 3.05 to version 4.0.0. The new version didn't work the way I wanted, so I decided to downgrade it. It turned out pretty easy.

Once again: in the commands listed below replace tesseract with the name of the package that you want to downgrade.

Step 1. Run brew info tesseract and find the formula link. Example: https://github.com/Homebrew/homebrew-core/blob/master/Formula/tesseract.rb

Step 2. Open the formula link in your web browser, click "Raw" and note the URL. Example: https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/tesseract.rb

Step 3. Run brew log tesseract. Since homebrew uses git version control system, all changes to its formulae are stored in 'commits'. You need to choose the id (aka hash) of the commit that you want to downgrade to. The newest commits will be at the top. I picked a commit with the id 5df6eb919506a097b2efb1df34a16e3a147c8731

Step 4. Replace master in the URL from Step 2 with the commit id from Step 3. Example: https://raw.githubusercontent.com/Homebrew/homebrew-core/**5df6eb919506a097b2efb1df34a16e3a147c8731**/Formula/tesseract.rb

Step 5. Uninstall the newer version of the package from your system: brew uninstall tesseract

Step 6. Install the older version of the package using the URL from Step 4. Example: brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/5df6eb919506a097b2efb1df34a16e3a147c8731/Formula/tesseract.rb

Step 7. 'Pin' it: brew pin tesseract --- 'pinning' tells Homebrew to keep the older version when you do brew upgrade.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment