Railsをローカルに落として bundle install する時に以下のようなエラーが出た。
$ bundle install
...
...
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/USERNAME/.rbenv/versions/2.2.1/bin/ruby -r ./siteconf20150428-22330-11fwtg6.rb extconf.rb
checking for clang... yes
checking for Magick-config... no
checking for pkg-config... yes
checking for outdated ImageMagick version (<= 6.4.9)... *** 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/USERNAME/.rbenv/versions/2.2.1/bin/$(RUBY_BASE_NAME)
extconf.rb:79:in ``': No such file or directory - convert (Errno::ENOENT)
from extconf.rb:79:inblock in configure_compile_options' from /Users/USERNAME/.rbenv/versions/2.2.1/lib/ruby/2.2.0/mkmf.rb:911:in
block in checking_for'
from /Users/USERNAME/.rbenv/versions/2.2.1/lib/ruby/2.2.0/mkmf.rb:351:in `block (2 levels) in postpone'
from /Users/USERNAME/.rbenv/versions/2.2.1/lib/ruby/2.2.0/mkmf.rb:321:in `open'
from /Users/USERNAME/.rbenv/versions/2.2.1/lib/ruby/2.2.0/mkmf.rb:351:in `block in postpone'
from /Users/USERNAME/.rbenv/versions/2.2.1/lib/ruby/2.2.0/mkmf.rb:321:in `open'
from /Users/USERNAME/.rbenv/versions/2.2.1/lib/ruby/2.2.0/mkmf.rb:347:in `postpone'
from /Users/USERNAME/.rbenv/versions/2.2.1/lib/ruby/2.2.0/mkmf.rb:910:in `checking_for'
from extconf.rb:76:in `configure_compile_options'
from extconf.rb:15:in `initialize'
from extconf.rb:473:in `new'
from extconf.rb:473:in `'
extconf failed, exit code 1
Gem files will remain installed in /Users/USERNAME/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/rmagick-2.14.0 for inspection.
Results logged to /Users/USERNAME/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0-static/rmagick-2.14.0/gem_make.out
An error occurred while installing rmagick (2.14.0), and Bundler cannot continue.
Make sure thatgem install rmagick -v '2.14.0'
succeeds before bundling.
最後の行に書かれているコードを実行。
$ gem install rmagick -v 2.14.0
^CERROR: Interrupted
KYCNT1503-09:iemon2015summer USERNAME$ gem install rmagick -v '2.14.0'
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
/Users/USERNAME/.rbenv/versions/2.2.1/bin/ruby -r ./siteconf20150428-21845-1avtdpn.rb extconf.rb
checking for clang... yes
checking for Magick-config... no
checking for pkg-config... yes
checking for outdated ImageMagick version (<= 6.4.9)... *** 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/USERNAME/.rbenv/versions/2.2.1/bin/$(RUBY_BASE_NAME)
extconf.rb:79:in ``': No such file or directory - convert (Errno::ENOENT)
from extconf.rb:79:inblock in configure_compile_options' from /Users/USERNAME/.rbenv/versions/2.2.1/lib/ruby/2.2.0/mkmf.rb:911:in
block in checking_for'
from /Users/USERNAME/.rbenv/versions/2.2.1/lib/ruby/2.2.0/mkmf.rb:351:in `block (2 levels) in postpone'
from /Users/USERNAME/.rbenv/versions/2.2.1/lib/ruby/2.2.0/mkmf.rb:321:in `open'
from /Users/USERNAME/.rbenv/versions/2.2.1/lib/ruby/2.2.0/mkmf.rb:351:in `block in postpone'
from /Users/USERNAME/.rbenv/versions/2.2.1/lib/ruby/2.2.0/mkmf.rb:321:in `open'
from /Users/USERNAME/.rbenv/versions/2.2.1/lib/ruby/2.2.0/mkmf.rb:347:in `postpone'
from /Users/USERNAME/.rbenv/versions/2.2.1/lib/ruby/2.2.0/mkmf.rb:910:in `checking_for'
from extconf.rb:76:in `configure_compile_options'
from extconf.rb:15:in `initialize'
from extconf.rb:473:in `new'
from extconf.rb:473:in `'
extconf failed, exit code 1
Gem files will remain installed in /Users/USERNAME/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/rmagick-2.14.0 for inspection.
Results logged to /Users/USERNAME/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0-static/rmagick-2.14.0/gem_make.out
おや、エラーが出た。
ググっていると、brewであらかじめ imagemagick パッケージをインストールする必要があるとのことだった。
$ sudo brew install imagemagick
==> Installing dependencies for imagemagick: libtool, jpeg, libpng, freetype
==> Installing imagemagick dependency: libtool
==> Downloading https://homebrew.bintray.com/bottles/libtool-2.4.6.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libtool-2.4.6.yosemite.bottle.tar.gz
==> Caveats
In order to prevent conflicts with Apple's own libtool we have prepended a "g"
so, you have instead: glibtool and glibtoolize.
Error: Thebrew link
step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink share/info/libtool.info
/usr/local/share/info is not writable.
You can try again using:
brew link libtool
==> Summary
🍺 /usr/local/Cellar/libtool/2.4.6: 69 files, 3.8M
==> Installing imagemagick dependency: jpeg
==> Downloading https://homebrew.bintray.com/bottles/jpeg-8d.yosemite.bottle.2.tar.gz
######################################################################## 100.0%
==> Pouring jpeg-8d.yosemite.bottle.2.tar.gz
🍺 /usr/local/Cellar/jpeg/8d: 18 files, 776K
==> Installing imagemagick dependency: libpng
==> Downloading https://homebrew.bintray.com/bottles/libpng-1.6.17.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libpng-1.6.17.yosemite.bottle.tar.gz
🍺 /usr/local/Cellar/libpng/1.6.17: 17 files, 1.2M
==> Installing imagemagick dependency: freetype
==> Downloading https://homebrew.bintray.com/bottles/freetype-2.5.5.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring freetype-2.5.5.yosemite.bottle.tar.gz
🍺 /usr/local/Cellar/freetype/2.5.5: 60 files, 2.6M
==> Installing imagemagick
==> Downloading https://homebrew.bintray.com/bottles/imagemagick-6.9.1-1.yosemite.bottle.tar.gz
######################################################################## 100.0%^
==> Pouring imagemagick-6.9.1-1.yosemite.bottle.tar.gz
🍺 /usr/local/Cellar/imagemagick/6.9.1-1: 1442 files, 22M
imagemagickが無事に入ったところで、rmagickを再インストール。
$ gem install rmagick -v '2.14.0'
...
...
Building native extensions. This could take a while...
Successfully installed rmagick-2.14.0
Parsing documentation for rmagick-2.14.0
Installing ri documentation for rmagick-2.14.0
Done installing documentation for rmagick after 7 seconds
1 gem installed
今度は入った。もう一度、各種パッケージをインストール。
$ bundle install
...
...
>Bundle complete! 29 Gemfile dependencies, 148 gems now installed.
Usebundle show [gemname]
to see where a bundled gem is installed.
これで無事に、Gemfile群がインストールされた。