Homebrewで過去versionをインストール

表題の通り。先日のansibleの件では、過去versionもインストールしていたのを残していたので`brew switch`することが可能であったが、インストールしていない過去のversionを使用したい場合、どうやってインストールするのかを知らなかったので調べて実践。

■ 環境

  • Mac OSX (10.10.5)
  • Homebrew 0.9.5

■ 以前のHomebrew

`brew versions`で過去versionを調べ、`git checkout`でインストールしたいversionにFormulaファイルを変更しインストールすることが可能のようであった。現在は`brew versions`コマンドは削除されてしまっているようである。

ということで別の手段にて実行する。

■ homebrew/versions

複数versionのFormulaを扱っているらしい。試しに”ansible“で過去versionをインストールしてみる。

$ brew search ansible
ansible (installed)
homebrew/versions/ansible14       homebrew/versions/ansible18
$

ansible“は”1.9.3“をインストールしていた元々使っているもの。それ以外に”homebrew/versions/ansible14“と”homebrew/versions/ansible18“というものがあるようだ。それぞれ”1.4“系と”1.8“系なのであろう。

ここでは”1.8“系をインストールする。

$ brew install homebrew/versions/ansible18
==> Tapping homebrew/versions
Cloning into '/usr/local/Library/Taps/homebrew/homebrew-versions'...
remote: Counting objects: 250, done.
remote: Compressing objects: 100% (237/237), done.
remote: Total 250 (delta 24), reused 105 (delta 13), pack-reused 0
Receiving objects: 100% (250/250), 267.44 KiB | 116.00 KiB/s, done.
Resolving deltas: 100% (24/24), done.
Checking connectivity... done.
Tapped 247 formulae (271 files, 1.5M)
==> Installing ansible18 from homebrew/homebrew-versions
Error: Cannot install homebrew/versions/ansible18 because conflicting formulae are installed.

  ansible: because Differing versions of same formula

Please `brew unlink ansible` before continuing.

Unlinking removes a formula's symlinks from /usr/local. You can
link the formula again after the install finishes. You can --force this
install, but the build may fail or cause obscure side-effects in the
resulting software.
$

既に”ansible“をインストール済みなので、インストールできなかったようだ。表示の通り`brew unlink`して再度試す。

$ brew unlink ansible
Unlinking /usr/local/Cellar/ansible/1.9.2... 12 symlinks removed
$
$ brew info ansible
ansible: stable 1.9.3 (bottled), HEAD
Automate deployment, configuration, and upgrading
http://www.ansible.com/home
/usr/local/Cellar/ansible/1.9.0.1 (1367 files, 16M)
  Poured from bottle
/usr/local/Cellar/ansible/1.9.2 (3774 files, 44M)
  Poured from bottle
/usr/local/Cellar/ansible/1.9.3 (4933 files, 60M)
  Poured from bottle
  :
$

*“が消えた。この状態でインストールする。

$ brew install homebrew/versions/ansible18
==> Installing ansible18 from homebrew/homebrew-versions
==> Downloading https://homebrew.bintray.com/bottles-versions/ansible18-1.8.4.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring ansible18-1.8.4.yosemite.bottle.tar.gz
  /usr/local/Cellar/ansible18/1.8.4: 1324 files, 15M
$

インストールされた。`brew list`で確認。

$ brew list
ansible
ansible18
  :
$

ansible“と”ansible18“とで別物としてインストールされたようである。

$ brew info ansible18
homebrew/versions/ansible18: stable 1.8.4 (bottled)
A radically simple IT automation platform.
http://www.ansible.com/home
Conflicts with: ansible
/usr/local/Cellar/ansible18/1.8.4 (1324 files, 15M) *
  Poured from bottle
From: https://github.com/Homebrew/homebrew-versions/blob/master/ansible18.rb
==> Dependencies
Required: libyaml ✔
$

*“が”1.8.4“についている。実際に`ansible`のコマンドからversionを確認。

$ ansible --version
ansible 1.8.4
  configured module search path = None
$

確かに”1.8.4“が適用されている。

今回はメジャーバージョンを下げることはできたが、マイナーバージョンを下げるにはどうしたら良いのであろう?やはりFormulaファイルを`git checkout`するのが一番良いのだろうか…。また調べてみる。

ちなみに、”1.8.4“にしてしまった”ansible“を”1.9.2“に戻すには下記。

$ brew unlink ansible18
Unlinking /usr/local/Cellar/ansible18/1.8.4... 12 symlinks removed
$
$ brew link ansible
Linking /usr/local/Cellar/ansible/1.9.2... 12 symlinks created
$
$ ansible --version
ansible 1.9.2
  configured module search path = None
$

1.9“系の`brew switch`したversionに戻っていることが確認できるであろう。

以上。

■ 関連