LoginSignup
138
98

More than 5 years have passed since last update.

Homebrewで旧バージョンをインストールする方法(brew versionsはもう使えない)

Last updated at Posted at 2016-01-12

OSごと再インストールしたMacにRabbitを入れようとしたら、エラーが出て入らなかったので、Homebrewと格闘していました。

中でもbrew versionsコマンドが使えなくなっていたのが一番困ったので、対処法についてまとめます。

旧バージョンが提供されている場合

一番楽ちんなパターン。

Homebrew公式で旧バージョンが提供されている場合。

brew tap homebrew/versionsで旧バージョン提供用のリポジトリを追加し、brew searchで検索。

$ brew search versions/ruby
homebrew/versions/ruby182    homebrew/versions/ruby187    homebrew/versions/ruby193    homebrew/versions/ruby21
homebrew/versions/ruby186    homebrew/versions/ruby192    homebrew/versions/ruby20

Rubyだとこんな感じになります。

多分各バージョンの最終版しかないので、もっと細かい単位で指定したい場合は他の方法を使います。

brew upgradeしたら動かなくなった場合

手元の環境で旧バージョンを使ったことがあるのなら、brew switchコマンドで過去のバージョンに切り替えることができます。

まずbrew infoで手元にどのバージョンが残っているかを確認します。

$ brew info poppler                                                                      oppler: stable 0.39.0 (bottled) [pinned at 0.39.0]
PDF rendering library (based on the xpdf-3.0 code base)
http://poppler.freedesktop.org
Conflicts with: pdftohtml
/usr/local/Cellar/poppler/0.38.0 (473 files, 22.4M)
  Poured from bottle
/usr/local/Cellar/poppler/0.39.0 (473 files, 22.4M) *
  Poured from bottle
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/poppler.rb

「*」がついている方が現在のバージョンです。

brew switchで一つ前のバージョンに切り替えます。

$ brew switch poppler 0.38.0
Cleaning /usr/local/Cellar/poppler/0.38.0
Cleaning /usr/local/Cellar/poppler/0.39.0
42 links created for /usr/local/Cellar/poppler/0.38.0

どちらも使えないとき

対象パッケージのFormulaファイルをGitで巻き戻してインストールすることができます。

/usr/local/Library/FormulaにFormulaファイルが入っているので、ここでgit logを使って旧バージョン時点のコミットを探します。

$ cd /usr/local/Library/Formula

$ git log poppler.rb
commit ad64e01ff4e4569f6a1e8c09b480d9c045aaf513
Author: BrewTestBot <brew-test-bot@googlegroups.com>
Date:   Mon Dec 21 16:03:44 2015 +0000

    poppler: update 0.39.0 bottle.

commit 7dba60ed43aaf747de01401bfe224c35c7fb8138
Author: Alexis Hildebrandt <afh@surryhill.net>
Date:   Thu Dec 17 16:51:55 2015 +0100

    poppler 0.39.0

    Closes #47114.

    Signed-off-by: Andrew Janke <andrew@apjanke.net>

commit 6f7b9d57b25451e811e8901c560d17abd7a464f9
Author: BrewTestBot <brew-test-bot@googlegroups.com>
Date:   Mon Dec 7 21:33:52 2015 +0000

    poppler: update 0.38.0 bottle.

commit 1b1c724b8db9ec68e2ac714e27cb44768f23afa6
Author: luzpaz <luzpaz@users.noreply.github.com>
Date:   Mon Dec 7 12:50:09 2015 -0600

    poppler 0.38.0

最新版は0.39.0で、上から3つ目のコミットが1つ前の0.38.0のようです。

コミットのハッシュ値を指定してgit checkoutしてFormulaファイルを巻き戻します。

$ git checkout 6f7b9d57b25451e811e8901c560d17abd7a464f9 poppler.rb

そしてbrew installすると、旧バージョンのFormulaファイルを使ってインストールされます。

$ brew install poppler
==> Downloading https://homebrew.bintray.com/bottles/poppler-0.38.0.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring poppler-0.38.0.el_capitan.bottle.tar.gz
🍺  /usr/local/Cellar/poppler/0.38.0: 473 files, 22.4M

最後に

大体書いた段階で欲しかった情報が全部まとまってる記事を見つけてしまったけど、このまま公開します。

gem install rabbit に失敗したのを解決した

138
98
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
138
98