Edited at

gem install rmagickで失敗する。

More than 1 year has passed since last update.


gem install rmagick でこけた

$gem install rmagick

Installing rmagick 2.15.4 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

/home/hogeuser/.rvm/rubies/ruby-2.1.7/bin/ruby -r ./siteconf20151217-27738-ufbalb.rb extconf.rb
checking for gcc... yes
checking for Magick-config... yes
checking for outdated ImageMagick version (<= 6.4.9)... no
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
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
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
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
checking for Ruby version >= 1.8.5... yes
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.15.4. 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:
--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=/home/hogeuser/.rvm/rubies/ruby-2.1.7/bin/ruby

extconf failed, exit code 1

Gem files will remain installed in /home/hogeuser/.rvm/gems/ruby-2.1.7/gems/rmagick-2.15.4 for inspection.
Results logged to /home/hogeuser/.rvm/gems/ruby-2.1.7/extensions/x86_64-linux/2.1.0/rmagick-2.15.4/gem_make.out
An error occurred while installing rmagick (2.15.4), and Bundler cannot continue.
Make sure that `gem install rmagick -v '2.15.4'` succeeds before bundling.

なぜか、普通に失敗した...ImageMagick もインストールしたのに...


MagickCore.pcが見つかってない見たいなので、"もの"があるか探す

ログを読むと

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

の行が目立つ... つまりMagickCore.pcが見つかっていないっぽい

ということでfind文を使って探してみる。

$ find /usr/lib64/pkgconfig -name MagickCore.pc

/usr/lib64/pkgconfig/MagickCore.pc

ふむふむ、普通に存在しているな...


MagickCore.pcがある場所にパスを通しつつgem installする。

ということで物は存在しているがパスが通っていないみたいだった

$ PKG_CONFIG_PATH='/usr/lib64/pkgconfig' gem install rmagick

Building native extensions. This could take a while...
Successfully installed rmagick-2.15.4
Parsing documentation for rmagick-2.15.4
Installing ri documentation for rmagick-2.15.4
Done installing documentation for rmagick after 6 seconds
1 gem installed

なんとかrmagickを入れることに成功!