Mac OSX に Homebrew をインストールする

Mac での開発環境を整えていきながら、メモしていきます。今回は、 Homebrew をインストールします。

Homebrew について

なにものか

MacUNIX ツールをインストールするために使用するパッケージ管理ソフトです。ソフトウェアをインストールし、依存関係を解消してくれるものだそうです。*1

MacPort との違い

パッケージ管理ソフトには、MacPort というのがありますが、いくつか違いがあります。

Homebrew MacPort
OS X に標準でインストールされているソフトウェア なるべく既存を利用する 新しくインストールする
インストールできるユーザ 一般ユーザ スーパーユーザ
ソフトウェアのインストールディレクト /usr/local /opt/user

上記は、参考資料*2をもとに、Homebrew と MacPort の違いを表形式にまとめたもので、特に新しい情報は付加されていません。また、この資料も参考になります。*3

インストールする

Homebrew Wiki のガイドに従ってインストールします。*4

環境と準備
  要求環境 インストールする環境 備考
プロセッサ Intel CPU 1.3 GHz Intel Core i5 「この Mac について」で確認
MacOS OS X 10.5以上 OS X 10.8.4(12E3067)
XCode Command Line Tools for Xcode or Xcode 3 XCode 4.6.3 Mac OSX に Xcode をインストールする - asa nisi masa
入力コマンド


$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"

出力


==> This script will install:
/usr/local/bin/brew
/usr/local/Library/...
/usr/local/share/man/man1/brew.1

Press ENTER to continue or any other key to abort
==> Downloading and Installing Homebrew...
remote: Counting objects: 121153, done.
remote: Compressing objects: 100% (58876/58876), done.
remote: Total 121153 (delta 84903), reused 94924 (delta 61307)
Receiving objects: 100% (121153/121153), 19.17 MiB | 2.22 MiB/s, done.
Resolving deltas: 100% (84903/84903), done.
From https://github.com/mxcl/homebrew
* [new branch] master -> origin/master
HEAD is now at 7d16d8c Cache pkgutil results at the source
==> Installation successful!
You should run `brew doctor' *before* you install anything.
Now type: brew help


既にインストールされている場合は、以下のガイダンスがでます。


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

インストールの確認

以下のコマンドを実行し、Homebrew が正しくインストールされていることを確認します。


$ brew doctor


=>いくつか、警告が出たので解消します。*5
具体的な警告と実施内容を以下に記載しますが、実施した内容を簡単に言うと、不要なファイルがあれば削除し、ファイル削除に伴ってリンク切れが発生したら解消するというもの。

警告その1


Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected dylibs:
/usr/local/lib/libmacfuse_i32.2.dylib
/usr/local/lib/libmacfuse_i64.2.dylib
/usr/local/lib/libosxfuse_i32.2.dylib
/usr/local/lib/libosxfuse_i64.2.dylib

=>余計なファイルを削除します


$ rm -rf /usr/local/lib/libmacfuse_i32.2.dylib
$ rm -rf /usr/local/lib/libmacfuse_i64.2.dylib
$ rm -rf /usr/local/lib/libosxfuse_i32.2.dylib
$ rm -rf /usr/local/lib/libosxfuse_i64.2.dylib

警告その2


Warning: Unbrewed .la files were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected .la files:
/usr/local/lib/libosxfuse_i32.la
/usr/local/lib/libosxfuse_i64.la

=>余計なファイルを削除します


$ rm -rf /usr/local/lib/libosxfuse_i32.la
$ rm -rf /usr/local/lib/libosxfuse_i64.la

警告その3


Warning: Unbrewed .pc files were found in /usr/local/lib/pkgconfig.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected .pc files:
/usr/local/lib/pkgconfig/osxfuse.pc

=>余計なファイルを削除します


$ rm -rf /usr/local/lib/pkgconfig/osxfuse.pc

警告その4


Warning: Broken symlinks were found. Remove them with `brew prune`:
/usr/local/lib/libosxfuse_i64.dylib
/usr/local/lib/libosxfuse_i32.dylib
/usr/local/lib/libosxfuse.dylib
/usr/local/lib/libosxfuse.2.dylib
/usr/local/lib/libmacfuse_i64.dylib
/usr/local/lib/libmacfuse_i32.dylib
/usr/local/lib/libfuse_ino64.dylib
/usr/local/lib/libfuse_ino64.2.dylib
/usr/local/lib/libfuse.dylib
/usr/local/lib/libfuse.2.dylib
/usr/local/lib/libfuse.0.dylib
/usr/local/lib/pkgconfig/fuse.pc
/usr/local/lib/libosxfuse.la

=>ファイルを削除した結果、リンクの切れたシンボリックリンクが発生してしまいました。以下のコマンドを実行し、Homebrewprefix からデッドシンボリックリンクを削除します。


$ brew prune
Pruned 0 dead formula
Pruned 13 symbolic links and 2 directories from /usr/local

再確認する


$ brew doctor
Your system is ready to brew.
brew は正常にインストールされました。

バージョンも確認する


$ brew -v
Homebrew 0.9.4

アンインストールする場合


$ rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup

使い方

コマンドの使い方は、以下を参照のこと。


Tips を眺めていたら、インストール終了時のビールアイコンを表示しないオプションもありました ww *6


export HOMEBREW_NO_EMOJI=1