kawasaki.rbで東京オリンピックのロゴの画像を作成してみたって話を聞いて、再現したくなった。がcairoのインストール部分で苦戦したので投稿
brewが通らない?
$ gem install cairo
Building native extensions. This could take a while...
ERROR: Error installing cairo:
ERROR: Failed to build gem native extension.
/Users/ShinichiMinoshima/.rbenv/versions/2.1.5/bin/ruby -r ./siteconf20150829-9567-mgx3xj.rb extconf.rb
checking for GCC... yes
checking for Win32 OS... no
checking for cairo version (>= 1.2.0)... no
checking for brew... yes
installing 'cairo' native package... failed
failed to run 'brew install cairo'.
*** 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:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/currentuser/.rbenv/versions/2.1.5/bin/ruby
--with-pkg-config
--without-pkg-config
--with-override-variables
--without-override-variables
extconf failed, exit code 1
homebrew のところで
何か必要なものが足りなくて失敗したんだろうけど、下で提示されているコマンドは違うような気がする。
似たような事例
Mac OS X & Homebrewでcairoのインストール
http://teppeis.hatenablog.com/entry/20120103/1325598908
$ brew install cairo
で、失敗。gccでコンパイルしたらインストールに成功したケースです。
gcc指定でインストール成功
$ brew install cairo --use-gcc
$ brew install cairo --use-gcc
==> Installing dependencies for cairo: libpng, freetype, fontconfig, pixman, gettext, libffi, glib
==> Installing cairo dependency: libpng
==> Downloading https://homebrew.bintray.com/bottles/libpng-1.6.18.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libpng-1.6.18.yosemite.bottle.tar.gz
🍺 /usr/local/Cellar/libpng/1.6.18: 17 files, 1.2M
(中略)
==> Installing cairo
==> Downloading https://homebrew.bintray.com/bottles/cairo-1.14.2_1.yosemite.bottle.3.tar.gz
######################################################################## 100.0%
==> Pouring cairo-1.14.2_1.yosemite.bottle.3.tar.gz
🍺 /usr/local/Cellar/cairo/1.14.2_1: 111 files, 6.1M
依存性ファイルがいっぱい。
(追記)(重要) sudo で インストール
$ sudo gem install cairo
Building native extensions. This could take a while...
Successfully installed cairo-1.14.1
Parsing documentation for cairo-1.14.1
Installing ri documentation for cairo-1.14.1
Done installing documentation for cairo after 2 seconds
1 gem installed
教訓
そういえば、Rails環境を構築するのにmysql2とかを入れた時にも似たようなケースがあったかな?
トラブルシューティングでは、どのあたりでコケたかを把握し、その症状で絞り込む。と。