3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Amazon LinuxでRMagick 3.0.0 がインストールできない

Last updated at Posted at 2019-03-27

bundle updateの際にrmagickのインストールで詰まってしまったため、対処法のメモ。

発生した問題

Capistranoでrails製アプリケーションのデプロイ中、rmagickのインストールでエラーが発生しました。

00:14 bundler:install
      01 $HOME/.rbenv/bin/rbenv exec bundle install --path /var/www/app/shared/bundle --jobs 4 --without development test --deployment --quiet
      01 Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
      01
      01 current directory:
      01 /var/www/app/shared/bundle/ruby/2.6.0/gems/rmagick-3.0.0/ext/RMagick
      01 /home/client/.rbenv/versions/2.6.1/bin/ruby -I
      01 /home/client/.rbenv/versions/2.6.1/lib/ruby/2.6.0 -r
      01 ./siteconf20190326-11939-1i8on2k.rb extconf.rb
      01 checking for gcc... yes
      01 checking for Magick-config... yes
      01 checking for outdated ImageMagick version (<= 6.8.9)... *** extconf.rb failed
      01 ***
      01 Could not create Makefile due to some reason, probably lack of necessary
      01 libraries and/or headers.  Check the mkmf.log file for more details.  You may
      01 need configuration options.
      01
      01 Provided configuration options:
      01    --with-opt-dir
      01    --without-opt-dir
      01    --with-opt-include
      01    --without-opt-include=${opt-dir}/include
      01    --with-opt-lib
      01    --without-opt-lib=${opt-dir}/lib
      01    --with-make-prog
      01    --without-make-prog
      01    --srcdir=.
      01    --curdir
      01    --ruby=/home/client/.rbenv/versions/2.6.1/bin/$(RUBY_BASE_NAME)
      01
      01 To see why this extension failed to compile, please check the mkmf.log which can
      01 be found here:
      01
      01 /var/www/app/shared/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0-static/rmagick-3.0.0/mkmf.log
      01
      01 extconf failed, exit code 1
      01
      01 Gem files will remain installed in
      01 /var/www/app/shared/bundle/ruby/2.6.0/gems/rmagick-3.0.0 for
      01 inspection.
      01 Results logged to
      01 /var/www/app/shared/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0-static/rmagick-3.0.0/gem_make.out
      01
      01 An error occurred while installing rmagick (3.0.0), and Bundler cannot continue.
      01 Make sure that `gem install rmagick -v '3.0.0' --source 'https://rubygems.org/'`
      01 succeeds before bundling.
      01
      01 In Gemfile:
      01   rmagick

エラーログの指示通り、 /var/www/app/shared/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0-static/rmagick-3.0.0/mkmf.log を確認します。

$ cat /var/www/app/shared/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0-static/rmagick-3.0.0/mkmf.log
find_executable: checking for gcc... -------------------- yes

--------------------

find_executable: checking for Magick-config... -------------------- yes

--------------------

Detected ImageMagick version: 6.7.8
Can't install RMagick 3.0.0. You must have ImageMagick 6.8.9 or later.
Can't install RMagick 3.0.0. You must have ImageMagick 6.8.9 or later.

ImageMagickのバージョンが古いのが原因のようですね。バージョンを上げましょう

ImageMagickのバージョンを上げる

RMagickはImageMagick7系をサポートしていないので、6.9系をインストールします。

Remiのリポジトリをインストール

ImageMagickの6.9系のバージョンが配布されているRemiリポジトリをインストールします。

//yumリポジトリにEPELを追加
yum install epel-release

//Remiのリポジトリ設定パッケージをダウンロード
wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

//Remiのリポジトリのインストール
rpm -Uvh remi-release-7.rpm

古いパッケージを削除

$ yum remove -y libtiff
$ yum remove -y graphviz
$ yum remove -y libwebp libwebp-devel
$ yum remove -y ImageMagick ImageMagick-devel ImageMagick-libs

新しいパッケージをインストール

$ yum install -y libtiff --enablerepo=remi,epel,base
$ yum install -y graphviz --enablerepo=remi,epel,base
$ yum install -y ImageMagick6 ImageMagick6-devel ImageMagick6-libs --enablerepo=remi,epel,base

バージョンの確認

$ convert --version
Version: ImageMagick 6.9.10-34 Q16 x86_64 2019-03-18 https://imagemagick.org
Copyright: © 1999-2019 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo djvu fftw fontconfig freetype gslib gvc jbig jng jp2 jpeg lcms ltdl lzma openexr pangocairo png ps raw rsvg tiff webp wmf x xml zlib

6.9.10をインストールできました。この後 bundle install を実行すると無事RMagickのインストールができました。
以上です。

参考

http://webdew.hateblo.jp/entry/2016/05/19/044105
https://qiita.com/iharakenji/items/dc9a2ce254dcdd2e97a0

3
3
0

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
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?