Bundlerでrmagicをインストール on Mac OS X Mavericks using Homebrew

Homebrewでimagemagickをインストールし、Gemfileに「gem "rmagick" require: "RMagick"」を追加してbundleを実行すると、rmagickのビルド中に

...
No package 'MagickCore' found
checking for stdint.h... yes
checking for sys/types.h... yes
checking for wand/MagickWand.h... no

Can't install RMagick 2.13.2. Can't find MagickWand.h.
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
...

というエラーが発生する。
このエラーは環境変数C_INCLUDE_PATHに"/usr/local/Cellar/imagemagick/6.8.8-9/include/ImageMagick-6" (imagemagick 6.8.8-9の場合)を設定すれば回避できる。
が、今度は

...
Package MagickCore was not found in the pkg-config search path.
Perhaps you should add the directory containing `MagickCore.pc'
to the PKG_CONFIG_PATH environment variable
No package 'MagickCore' found
Can't install RMagick 2.13.2. Can't find the ImageMagick library or one of the dependent libraries. Check the mkmf.log file for more detailed information.

*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
...

と言われる。
こちらはPKG_CONFIGに "/usr/local/Cellar/imagemagick/6.8.8-9/lib/pkgconfig" (この値もあくまでimagemagickのバージョンが6.8.8-9の場合の話)を設定すればよい。


環境変数はビルド時だけ指定すればいいので、わざわざbashrcとかに書く必要はなく、bundleを実行する時に

$ C_INCLUDE_PATH="/usr/local/Cellar/imagemagick/6.8.8-9/include/ImageMagick-6" PKG_CONFIG_PATH="/usr/local/Cellar/imagemagick/6.8.8-9/lib/pkgconfig" bundle install --path vendor/bundle

みたいな感じにすればOK。

Comments

Popular posts from this blog

TFS: 別PCでのチェックアウトを取り消す

WPF の RichTextBox に文字列を設定する&取り出す

WPFアプリにアニメーションGIFを表示させる