Skip to content

Instantly share code, notes, and snippets.

@jpluimers
Forked from nickcernis/old-version-homebrew.md
Created November 6, 2024 12:50
Show Gist options
  • Save jpluimers/8da7d1f366936b0363e98b8baef1af98 to your computer and use it in GitHub Desktop.
Save jpluimers/8da7d1f366936b0363e98b8baef1af98 to your computer and use it in GitHub Desktop.
Install an old version with homebrew for macOS
  1. Find the formula for the version you want to install:

    • Visit https://github.com/Homebrew/homebrew-core/tree/master/Formula
    • Click the file with your formula (e.g. “composer.rb”)
    • Click “History” (top right)
    • Click the commit hash for the version you want to download
    • Click the three dots (top right of diff) and choose “view file”
    • Click “Raw” and copy the raw URL from the browser address bar.

    For example, composer 1.10.15 lives here: https://github.com/Homebrew/homebrew-core/blob/9e6e6a1ca8551901bff69d329c7fbb9007064134/Formula/composer.rb

    With the raw file at: https://raw.githubusercontent.com/Homebrew/homebrew-core/9e6e6a1ca8551901bff69d329c7fbb9007064134/Formula/composer.rb

  2. Download the raw formula to disk:

    cd ~/Desktop
    curl -O https://raw.githubusercontent.com/Homebrew/homebrew-core/9e6e6a1ca8551901bff69d329c7fbb9007064134/Formula/composer.rb
  3. Install that recipe from disk:

    brew install composer.rb (change composer.rb to the formula name)

  4. Clean up:

    rm composer.rb (change composer.rb to the formula name)

  5. Check the version for whatever you just installed:

    ❯ composer --version
    Composer version 1.10.15 2020-10-13 15:59:09
@jpluimers
Copy link
Author

jpluimers commented Nov 6, 2024

For casks, steps based on https://stackoverflow.com/questions/58373704/how-do-you-specify-a-version-using-brew-cask

Cask example: beyond compare where I wanted version 4

  1. Find the ruby file in the casks: https://github.com/Homebrew/homebrew-cask/tree/master/Casks

  2. In this case https://github.com/Homebrew/homebrew-cask/blob/master/Casks/b/beyond-compare.rb

  3. Click on History go get to the commits for beyond-compare.rb file

  4. In this case: https://github.com/Homebrew/homebrew-cask/commits/master/Casks/b/beyond-compare.rb

  5. Find the most recent commit before the next version you don't want (we want the most recent 4.x which was 4.4.7.28397, so we get the commit just before the oldest 5.x which was 5.0.0.29773)

  6. In this case: Homebrew/homebrew-cask@7c66c95

  7. View the pretty-printed ruby file beyond-compare.rb

  8. In this case: https://github.com/Homebrew/homebrew-cask/blob/7c66c9516038b2d4a7d543340b0905f9fba0e439/Casks/b/beyond-compare.rb

  9. Click on the "RAW" button to view the RAW file

  10. In this case https://raw.githubusercontent.com/Homebrew/homebrew-cask/7c66c9516038b2d4a7d543340b0905f9fba0e439/Casks/b/beyond-compare.rb

  11. Download this file locally: curl --remote-name https://raw.githubusercontent.com/Homebrew/homebrew-cask/7c66c9516038b2d4a7d543340b0905f9fba0e439/Casks/b/beyond-compare.rb

  12. Install that one using prefix brew install --cask beyond-compare.rb

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