LoginSignup
1

More than 5 years have passed since last update.

homebrewでwatchmanインストールするときの制限

Last updated at Posted at 2017-05-06

tl:dr

  • 公式docに載ってるコンパイル用オプションを使いたいなら、homebrewダメ。ソースからコンパイルが(ほぼ)必須
  • 例外は --enable-statedir。これは、homebrewの環境変数を使って変更可能
  • homebrewのインストール先をカスタマイズしてるなら、 --enable-statedirを使わないといけない

homebrewのインストール先がデフォルト(/usr/local)の場合

brew install watchman

でOK

homebrewのインストール先をカスタマイズしてる環境

  • 自分がこれに該当
  • $HOMW/homebrewに設定している

発生する問題

brew install watchmanでインストールされても、起動でコケる

# エラーの出力の例
while computing sockname: 
failed to create /usr/local/var/run/watchman/sakymrk-state: No such file or directory

起動時に設定ファイルを/usr/local以下に作ろうとして(権限がないため)コケる

brew install watchman ではインストールオプションが指定できない

watchmanのドキュメントに載ってる、compile-time-configuration-optionsを参考に、--enable-statedirオプションを使おうとしても、homebrewは無視する。

  • watchmanのFormulaでオプションが定義されていない
    • brew info watchman を実行しても==> Options のセクションが無い
  • そのため、このオプションに限らずすべてのコンパイルオプションは無視される

解決方法

watchmanのFormulaみると、変数prefixvarにホームディレクトリなど別のpathを渡せば、解決できることがわかる。

# watchmanのFormulaファイルの抜粋
# https://github.com/Homebrew/homebrew-core/blob/master/Formula/watchman.rb#L24-L29

  def install
    system "./autogen.sh"
    system "./configure", "--disable-dependency-tracking",
                          "--prefix=#{prefix}",
                          "--with-pcre",
                          # we'll do the homebrew specific python
                          # installation below
                          "--without-python",
                          "--enable-statedir=#{var}/run/watchman"
    system "make"
    system "make", "install"

Formula Cookbookよむと、

  • varprefixの値から派生的に決まる
  • 環境変数HOMEBREW_PREFIXをセットすれば、prefixの値をデフォルトの/usr/local/から変更可能

とわかる

インストール方法

これでOK

# Good!
HOMEBREW_PREFIX=$(brew --prefix) brew install watchman

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1