LoginSignup
19
15

More than 5 years have passed since last update.

gem install rmagick でインストール失敗

Last updated at Posted at 2017-01-20

数々の解決方法が、Webには転がっていた.

http://qiita.com/hiroara@github/items/6b1c6c7257042a159cc9
http://qiita.com/tomomomo1217/items/79f516fc0c483e68f444
http://qiita.com/shunhikita/items/4a2afd978742c9d3cc7f
http://qiita.com/KTakata/items/f4a632207af0a8078c06

しかし、今回のケースはどれにも当はまらなかったので、独自の解決方法を記す。

環境

Mac : 10.12.2
Ruby: 2.2.2
ImageMagick : 6.9.1

経緯

最初、brew によって、ImageMagic をインストールして、gem install rmagick を実行していたが、下記のエラーが頻発する。

$ gem install rmagick -v '2.16.0'
Building native extensions.  This could take a while...
ERROR:  Error installing rmagick:
        ERROR: Failed to build gem native extension.

    /Users/xxxx/.rbenv/versions/2.2.2/bin/ruby -r ./siteconf20170121-33287-t9qj7o.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)... no
checking for presence of MagickWand API (ImageMagick version >= 6.9.0)... no
checking for Ruby version >= 1.8.5... yes
checking for stdint.h... yes
checking for sys/types.h... yes
checking for wand/MagickWand.h... no

Can't install RMagick 2.16.0. 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:
        --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/xxxx/.rbenv/versions/2.2.2/bin/$(RUBY_BASE_NAME)

extconf failed, exit code 1

そこで、このサイトから、直接ダウンロードしてインストールした。
http://cactuslab.com/imagemagick/

デフォルトでは、下記のディレクトリにインストールされる。

/opt/ImageMagick

brewでのインストール

参考までに、brew でインストールした場合は、下記にインストールされる。

/usr/local/Cellar/imagemagick

今回は重複しない為に、以前brewでインストールしたものはアンインストールした。

$ brew uninstall ImageMagick

ImageMagickの確認

念の為、ImageMagickが、想定通りのものか確認するために、下記コマンドにて確認。

$ convert --version
Version: ImageMagick 6.9.1-0 Q16 x86_64 2015-03-22 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: DPC OpenCL
Delegates (built-in): bzlib fftw jng jpeg lcms lzma png tiff webp xml zlib
$ which convert
/opt/ImageMagick/bin/convert

環境変数設定

環境変数 PKG_CONFIG_PATHにpkgconfigを追記する。

$ vi .bash_profile

# Setting PATH for ImageMagick
export PKG_CONFIG_PATH=/opt/ImageMagick/lib/pkgconfig

$ source .bash_profile

rmagickのインストール

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

まとめ

ポイントとしては、
 1. brew で、ImageMagic をインストールしない。
 2. PKG版のImageMagicをインストールして、pkgconfig ディレクトリを環境変数に追記する。

なかなか、しんどかった。

19
15
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
19
15