Downgrade any Homebrew package easily

Update from 2020: the instructions for tesseract don’t work anymore, see comments from other users below the post.

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.

This entry was posted in How to’s and tagged , . Bookmark the permalink.

14 Responses to Downgrade any Homebrew package easily

  1. Timmy says:

    Wow, this worked very smoothly indeed. Thank you very much indeed – this was a lifesaver with llvm. `pin` appears to be a very useful command. I shall be using it extensively from now on (especially given the propensity of LLVM to break something with every minor version upgrade).

  2. Saleh says:

    This worked like a charm for me. Thank you

  3. Denis says:

    Thank you for sharing! It works for me as well!

  4. Tony Dunn says:

    Worked like a charm, and saved my life after a vim upgrade broke hideously for me, many *many* thanks for this.

  5. Anshul says:

    Very cool..Thx for sharing..Worked like a charm

  6. Gonteri Filippo says:

    Hello !
    Was so happy to read your post… but this is the result
    Warning: Calling Installation of tesseract from a GitHub commit URL is deprecated! Use ‘brew extract tesseract’ to stable tap on GitHub instead.
    Error: tesseract: “cxx11” is not a recognized standard
    Can’t downgrade with your method (El Capitan)
    Any workaround ? Audiveris generate an error and mxl files exports are corrupted !
    Thanks for your help.
    Filippo

    • Dae says:

      Hello, I’ve just tried brew extract --version='3.05.02' tesseract dae/dae and ran into the same problem. Unfortunately I don’t know how to solve this, sorry.

    • Arthur says:

      Just download the github file locally and run it with: ‘brew install ./tesseract.rb’

      this worked for me – i found the suggestion from Micah Ramos here: https://medium.com/@micah.p.ramos/if-you-get-82b859ee5f9a

      • hey Arthur,

        Thanks for this. In my case i was trying to downgrade Hugo — saving the rb file locally and just simply installing from there works and got me beyond this error:

        “Error: Calling Non-checksummed download of hugo formula file from an arbitrary URL is disabled! Use ‘brew extract’ or ‘brew create’ and ‘brew tap-new’ to create a formula file in a tap on GitHub instead.”

  7. Neto Sena says:

    Hi Guys,
    Unfortunately for me doen’t work.

    I have to download the file and execute the command
    brew install ./tesserac.rb

    it showed up:
    Error: No similarly named formulae found.
    Error: No available formula or cask with the name “./tesseract.rb”.

    I don’t know what to do.

    Thanks

    • David says:

      I ran into the same issue because I renamed my .rb file when I downloaded it to my computer – that turned out to be the problem as the install appears to rely on the file name. Make sure it’s exactly the same as in the Github link. It looks like you perhaps misspelled it above: brew install ./tesserac.rb

  8. Koo says:

    After brew updated, Download and execute work for me.

    example : brew install ./package-name.rb

    thank you for your updated comment.

  9. gp says:

    Am I suppose to see something from brew log? When I run that in my case ‘brew log helix’ I get nothing

Leave a Reply

Your email address will not be published. Required fields are marked *