WEB Engineer Architect Tips

WEBサービス開発における、技術やアーキテクチャ、ツールにテクニックなど……困ったときに思わずちょい見したくなるようなTips集です。

SublimeText3 導入 with Homebrew / Git Part.1

そもそもHomebrewって何だっけ?という浦島太郎状態でしたので、もろもろ環境の最新化からおこなっていきます。

まず、Homebrewを最新化しようとbrew updateコマンドを実行したところ、Warningが発生しました。

Curiosity% brew update
Checking out files: 100% (3209/3209), done.
warning: inexact rename detection was skipped due to too many files.
warning: you may want to set your diff.renameLimit variable to at least 957 and retry the command.
Error: undefined method `to_sym' for nil:NilClass
Please report this bug:
https://github.com/mxcl/homebrew/wiki/troubleshooting
/usr/local/Library/Homebrew/cmd/update.rb:99:in `report'
/usr/local/Library/Homebrew/cmd/update.rb:97:in `each_line'
/usr/local/Library/Homebrew/cmd/update.rb:97:in `report'
/usr/local/Library/Homebrew/cmd/update.rb:18:in `update'
/usr/local/bin/brew:94:in `send'
/usr/local/bin/brew:94

brew update で to_sym エラーが出た時の対処方法 - Qiitahomebrewアップデート/アンインストール - CROSS HOPEを参考にしながら
brew doctorにて原因の調査を行ったところ、Warningがいくつか起きています。

Warning: A newer Command Line Tools release is available.
The standalone package can be obtained from
https://developer.apple.com/downloads
or it can be installed via Xcode's preferences.

Warning: /usr/bin occurs before /usr/local/bin
This means that system-provided programs will be used instead of those
provided by Homebrew. The following tools exist at both paths:

c_rehash
git
git-cvsserver
git-receive-pack
git-shell
git-upload-archive
git-upload-pack
gitk
openssl

Consider setting your PATH so that /usr/local/bin
occurs before /usr/bin. Here is a one-liner:
echo export PATH='/usr/local/bin:$PATH' >> ~/.bash_profile

早速、brew upgradeを実行。すると、特にエラーも無く無事完了
再度brew updateを実行すると、無事終了したようです。

Updated Homebrew from afda72f5 to 74305bf5.
==> Updated Formulae
monetdb

ですが、引き続きbrew doctorは同様のwarningを吐き続けています……汗

Warning: A newer Command Line Tools release is available.
The standalone package can be obtained from
https://developer.apple.com/downloads
or it can be installed via Xcode's preferences.

Warning: /usr/bin occurs before /usr/local/bin
This means that system-provided programs will be used instead of those
provided by Homebrew. The following tools exist at both paths:

git
git-cvsserver
git-receive-pack
git-shell
git-upload-archive
git-upload-pack
gitk

Consider setting your PATH so that /usr/local/bin
occurs before /usr/bin. Here is a one-liner:
echo export PATH='/usr/local/bin:$PATH' >> ~/.bash_profile

次に、http://blog.pinkpinkpink.net/2012/07/homebrew.htmlを参考に、すべてのWarningを消しにいきます。
まずは、1つめのCommand Line Toolsに関するWarning。こちらはXCodeにて新しいVersionを使えるよ、ってことみたいです。

解決法 #1
Xcodeを起動し、Preference > Downloads を開く。
Command Line Tools をインストールする。(約5分くらいかかる)


画像のようにチェックマークになり、再度Homebrewを実行すると該当のWarningがなくなりました。

次に、/usr/bin occurs before /usr/local/bin のWarning。
こちらは以下の対応が必要なようです。

問題 #5
Warning: /usr/bin occurs before /usr/local/bin

解決法 #5
Consider amending your PATH so that /usr/local/bin
occurs before /usr/bin in your PATH.

このメッセージの通り、".bash_profile"のPATHを設定。

$ vi ~/.bash_profile
export PATH=/usr/local/bin:$PATH # 1行目に追加。

bashのProfileにて、上記のようにパスを通してあげる必要があるようです。
ですが、現在の環境で使用しているのはzsh。。
homebrew - brew installation for zsh? - Stack Overflowを読むに、

Try setting this line in your .zshrc
export PATH=/usr/local/bin:$PATH

$HOME/.zshrcに「export PATH=/usr/local/bin:$PATH」を追加すれば良いようです。
そもそも/.zshrcファイルがないのでとりあえず作ってみます。
ただ、現状echo $PATHをすると、
 「/usr/bin /bin /usr/sbin /sbin /usr/local/bin」と記載があります。
既に/usr/local/binが最後尾にあるため、最初に移動します↓
 「/usr/local/bin /usr/bin /bin /usr/sbin /sbin」
なので、
 export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

#PATH
#2014/05/28
#Homebrewのbrew doctor warning対応として順番を入替
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

としましょう。すると……

無事、brewの最新化が完了しました!(:P
本当はGitHubに共有したいところですが、まだGitHubのセットアップもしていないので、それは次回に。