チラシ裏日記上等!!新館

Webアプリケーションエンジニアの雑記帳。映画とかアニメとかの記事も書きます。

rmagickをインストールするとき明示的にgccを指定する

rmagickをbundle installでインストールするとき以下のエラーが出た。OSはOS X EI Capitan。

checking for /usr/bin/gcc-4.2... no
No C compiler found in ${ENV['PATH']}. See mkmf.log for details.
*** 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.

どうやら/user/bin/gcc-4.2がないのが原因らしい。あるのは/user/bin/gcc。コンソールでgcc --versionで調べてみたところ。

% gcc --version                                                                      (git)-[iss-6]
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.3.0 (clang-703.0.29)
Target: x86_64-apple-darwin15.3.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

と出たので。普通に4.2はインストールされている。これを使うように明示的に指定しないといけないっぽい。

なので以下のように実行したところちゃんとインストールできた。

CC=gcc bundle install

参考文献

stackoverflow.com