Lチカ開発ブログ

https://l-chika.com/の開発ブログ

1年ぶりにbrew updateした時のメモ

どんな時のため

  • MacのOSをバージョンアップしたりすると brew update がうまくいかない
  • 環境: macOs Sierra バージョン:10.12.2

きっかけ

開発はVagrantでしたりするけど、ローカルでサクッとrubyの動作をチェックしたいときに、rubyのバージョンを変更しようと、 brew upgrade rbenv ruby-build をしようと思ったら、エラーとなった

手順概要

  1. brew updateとupgrade
  2. rbenvのupdate
  3. bundler のupdate

brew updateとupgrade

$ brew update
Error: The /usr/local directory is not writable.
Even if this directory was writable when you installed Homebrew, other
software may change permissions on this directory. Some versions of the
"InstantOn" component of Airfoil are known to do this.

You should probably change the ownership and permissions of /usr/local
back to your user account.
  sudo chown -R $(whoami):admin /usr/local
Kernel.exit

$ sudo chown -R $(whoami):admin /usr/local
  • パーミッションを変更しても、さらにソース管理でエラーとなる場合は、git statsh
  • 必要なパッケージをupgrate
  • パーミッションは元に戻しても、戻さなくても
$ brew update

Could not restore untracked files from stash
Error: Failure while executing: git stash pop

$ cd /usr/local && git stash pop --quiet
$ brew update
$ brew upgrade rbenv ruby-build
$ sudo chown root:wheel /usr/local

rbenvのupdate

  • ruby 2.3.3をインストールする場合
$ rbenv install --list
$ rbenv install 2.3.3
$ rbenv versions
$ rbenv global 2.3.3
$ rbenv rehash
$ ruby -v

bundler のupdate

  • 特定バージョン以上のrubyをサポートしているgemをインストールする際に、なぜかbundle install 時にエラーになった
  • bundlerが利用しているバージョンが違ったためのよう

rubyとbundlerのパスを確認

$ which ruby
$ which bundle

違っている場合には以下を実行

$ rbenv exec gem install bundler
$ rbenv rehash
$ which bundle