読者です 読者をやめる 読者になる 読者になる

Homebrewが使えなくなった

Mac Homebrew
  • yosemiteに上げた時かその後のアップデートかわからないけどbrewが使えなくなってた。

エラー発生

$ brew update
/usr/local/bin/brew: /usr/local/Library/brew.rb: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or directory
/usr/local/bin/brew: line 21: /usr/local/Library/brew.rb: Undefined error: 0
  • rubyのバージョンを確認したらエラーが出てるのとは違う。
$ ruby -v
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]
  • エラー出してるファイル覗いてみたら1.8って書いてある。
$ view /usr/local/Library/brew.rb
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -W0

再インストール

  • 1.8をCurrentに書き換えたけどやっぱりダメだったので入れなおす。
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
It appears Homebrew is already installed. If your intent is to reinstall you
should do the following before running this installer again:
    rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
  • エラーで入れられないのでメッセージに従ってみる。
$ rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
/usr/local/bin/brew: /usr/local/Library/brew.rb: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or directory
/usr/local/bin/brew: line 21: /usr/local/Library/brew.rb: Undefined error: 0
  • brewコマンドが動かないので1.8のところをCurrentにしてcleanだけ流してみる。
$ vi /usr/local/Library/brew.rb
#!/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby -W0
$ brew cleanup
  • うまく行ったので、もっかい再インストール!
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
==> This script will install:
/usr/local/bin/brew
/usr/local/Library/...
/usr/local/share/man/man1/brew.1

Press RETURN to continue or any other key to abort
==> Downloading and installing Homebrew...
remote: Counting objects: 3608, done.
remote: Compressing objects: 100% (3450/3450), done.
remote: Total 3608 (delta 33), reused 673 (delta 19), pack-reused 0
Receiving objects: 100% (3608/3608), 2.88 MiB | 981.00 KiB/s, done.
Resolving deltas: 100% (33/33), done.
From https://github.com/Homebrew/homebrew
 * [new branch]      master     -> origin/master
HEAD is now at 5b7f4f2 mysql-connector-odbc: add 5.3.4 bottle.
==> Installation successful!
==> Next steps
Run `brew help` to get started
$ brew update

でけた〜。