Homebrewインストールのメモ

投稿者: | 2017-09-16

参考:実行中のRubyのバージョンを確認する – Qiita http://qiita.com/norifumi/items/3009a31c4ed23f97c336
Yukias-MBA:/ Yukias$ ruby –version
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]

Ruby – Homebrewのインストールとrbenvのインストール Mac編 – Qiita http://qiita.com/issobero/items/e0443b79da117ed48294
■rvmをインストールしている人は切腹して消しましょう。
rvm seppuku
# => rvm削除コマンド
rm -rf ~./rvm
# => ディレクトリも消しましょう!
→ディレクトリはなかった。
Homebrew本体のインストール
ruby -e “$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)”
→もうすでにインストールされているとのこと。
Yukias-MBA:/ Yukias$ 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
削除してくれと言われたら、Permission deniedで削除できなかった。

地引製作所 » Blog Archive » homebrew link で Permission denied http://jibiki.jp/wordpress/?p=937
色々調べてみると homebrew を使う場合は /usr/local/ をグループ:staff、パーミッション:775に設定しておく必要がある模様。
参考:
なので、以下のコマンドを実行。
$ sudo chgrp -R staff /usr/local
$ sudo chown -R 775 /usr/local
$
試したけどダメだった。
とりあえず、
$ sudo chgrp -R wheel /usr/local
$ sudo chown -R Yukias /usr/local
にした。

/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
のエラーが解決できない。
原因は、
Mac – Yosemiteでbrewが壊れた – Qiita http://qiita.com/sue738/items/7ab03ecc9f6fcf37408d
/usr/local/Library/brew.rb(変更前)
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -W0

/usr/local/Library/brew.rb(変更後)
#!/System/Library/Frameworks/Ruby.framework/Versions/current/usr/bin/ruby -W0

みたい。
コードを変更するのは危険そうだなあと。
で、調べたら、以下のような記事あり。
Git のローカルリポジトリを更新して Homebrew を最新に – CHROMA http://chroma.hatenablog.com/entry/2014/10/29/191638
Yukias-MBA:Library Yukias$ cd /usr/local/bin
Yukias-MBA:bin Yukias$ git pull origin master
fatal: Not a git repository (or any of the parent directories): .git
怒られた。
fatal: Not a git repository (or any of the parent directories): .git – uoz 作業日記 http://uozias.hatenablog.com/entry/2014/06/04/fatal%3A_Not_a_git_repository_%28or_any_of_the_parent_directories%29%3A__git
git init
したら、エラー増えた。
fatal: ‘origin/’ does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

とりあえず、仕方ないので、以下の内容の
homebrewユーザーがYosemiteにアプグレしたらbrewコマンドが使えなくなった問題解決法 – 現代版徒然草 (生まれてきたら負け) http://rrt.hateblo.jp/entry/2014/10/19/031312
viでbrew.rbの1行目を編輯します。
vi /usr/local/Library/brew.rb
— #!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -W0
+++ #!/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby -W0
をする。
ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
したらインストールできた。
Yukias-MBA:Library Yukias$ brew doctor
で、
Warning: You have uncommitted modifications to Homebrew
If this a surprise to you, then you should stash these modifications.
Stashing returns Homebrew to a pristine state but can be undone
should you later need to do so for some reason.
cd /usr/local/Library && git stash && git clean -d -f
がでたので試す。
Yukias-MBA:Library Yukias$ brew doctor
したら、エラーが消えた。
ほかにもエラーがいっぱい出てた。
brew prune
したら解決。
Yukias-MBA:Library Yukias$ brew doctor
Your system is ready to brew.
と出たのでインストールできたっぽい。
Yukias-MBA:Library Yukias$ brew -v
Homebrew 0.9.5