[macOS General] Homebrew: zsh 5.0.4 をインストールしたら path の様子がおかしかったので、5.0.2 に戻した

.zshrc は変更してないのですが、ログイン時に rbenv が行方不明に。
最終的に解決策を見つけることができました。

[markdown]

“`prettyprinted
Last login: Sat Dec 28 04:11:05 on ttys000
You have mail.
/Users/****/.zshrc:371: command not found: rbenv
%
“`

100% 再現するので、バージョンを戻せないか確認してみました。

## brew switch で、以前のバージョンに戻す

こちらに手順が載っていたので、試してみます。

> * [Homebrew install specific version of formula? – Stack Overflow](http://stackoverflow.com/questions/3987683/homebrew-install-specific-version-of-formula)

“`prettyprinted
% brew info zsh
zsh: stable 5.0.4
http://www.zsh.org/
/usr/local/Cellar/zsh/5.0.2 (963 files, 8.1M)
/usr/local/Cellar/zsh/5.0.4 (1063 files, 8.9M) *
Built from source
From: https://github.com/Homebrew/homebrew/commits/master/Library/Formula/zsh.rb
==> Dependencies
Required: gdbm ✔, pcre ✔
==> Options
–enable-etcdir
Enable the reading of Zsh rc files in /etc
==> Caveats
To use this build of Zsh as your login shell, add it to /etc/shells.
Add the following to your zshrc to access the online help:
unalias run-help
autoload run-help
HELPDIR=/usr/local/share/zsh/helpfiles
% brew switch zsh 5.0.2
Cleaning /usr/local/Cellar/zsh/5.0.2
Cleaning /usr/local/Cellar/zsh/5.0.4
924 links created for /usr/local/Cellar/zsh/5.0.2
“`

5.0.2 では問題なし。

“`prettyprinted
Last login: Sat Dec 28 04:15:55 on ttys003
You have mail.
%
“`

ruby のインストールではまったかと思ったけれども、Homebrew の問題なような気がしてきました。

## 解決策

ありがたいことに解決されている方を見つけました。
[/markdown]

[markdown]
この手順なんだけど、こわい。

“`prettyprinted
% brew uninstall zsh
% brew install zsh –enable-etcdir
“`

https://github.com/Homebrew/homebrew/blob/master/Library/Formula/zsh.rb
やってみることにする。

“`prettyprinted
% brew uninstall zsh
Uninstalling /usr/local/Cellar/zsh/5.0.2…
“`

あっ。switch しておけば、5.04 だけ消せたのかな?

“`prettyprinted
% brew switch zsh 5.0.4
Cleaning /usr/local/Cellar/zsh/5.0.4
1042 links created for /usr/local/Cellar/zsh/5.0.4
% brew uninstall zsh
Uninstalling /usr/local/Cellar/zsh/5.0.4…
VCS_INFO_bydir_detect:9: VCS_INFO_realpath: function definition file not found
“`

気を取り直して進めるも、エラーが出ている。
そのまま進めてみる。

“`prettyprinted
% brew install zsh –enable-etcdir
==> Downloading http://fossies.org/linux/misc/zsh-5.0.4.tar.bz2
Already downloaded: /Library/Caches/Homebrew/zsh-5.0.4.tar.bz2
==> ./configure –prefix=/usr/local/Cellar/zsh/5.0.4 –enable-fndir=/usr/local/C
==> make install
==> Caveats
To use this build of Zsh as your login shell, add it to /etc/shells.
Add the following to your zshrc to access the online help:
unalias run-help
autoload run-help
HELPDIR=/usr/local/share/zsh/helpfiles
==> Summary
/usr/local/Cellar/zsh/5.0.4: 1063 files, 8.9M, built in 2.4 minutes
“`

うまくいったようです。

“`prettyprinted
Last login: Sat Dec 28 05:23:22 on ttys001
You have mail.
% brew info zsh
zsh: stable 5.0.4
http://www.zsh.org/
/usr/local/Cellar/zsh/5.0.4 (1063 files, 8.9M) *
Built from source with: –enable-etcdir
From: https://github.com/Homebrew/homebrew/commits/master/Library/Formula/zsh.rb
==> Dependencies
Required: gdbm ✔, pcre ✔
==> Options
–enable-etcdir
Enable the reading of Zsh rc files in /etc
==> Caveats
To use this build of Zsh as your login shell, add it to /etc/shells.
Add the following to your zshrc to access the online help:
unalias run-help
autoload run-help
HELPDIR=/usr/local/share/zsh/helpfiles
“`

## バージョンを指定してインストールし直す

万が一の場合は、これで戻せそう。
と思ったら、Warning が出ていて怖い。

手順はこんな感じになるよう。

“`prettyprinted
% brew uninstall zsh
% brew versions zsh
Warning: brew-versions is unsupported and may be removed soon.
Please use the homebrew-versions tap instead:
https://github.com/Homebrew/homebrew-versions
5.0.4 git checkout 9ba7d27 Library/Formula/zsh.rb
5.0.3 git checkout 4d5b455 Library/Formula/zsh.rb
5.0.2 git checkout 52fe004 Library/Formula/zsh.rb
5.0.1 git checkout 9d0b1be Library/Formula/zsh.rb
5.0.0 git checkout 9928fbb Library/Formula/zsh.rb
4.3.17 git checkout 8022bf4 Library/Formula/zsh.rb
4.3.16 git checkout 94841e1 Library/Formula/zsh.rb
4.3.15 git checkout 0c7ed4d Library/Formula/zsh.rb
4.3.12 git checkout d8c1bd1 Library/Formula/zsh.rb
4.3.11 git checkout 0476235 Library/Formula/zsh.rb
4.3.10 git checkout d0efd9e Library/Formula/zsh.rb
% git checkout 52fe004 Library/Formula/zsh.rb
% brew install zsh
“`

> * [Ruben Ascencio : brew install specific version of formula](https://coderwall.com/p/lqphzg)
[/markdown]