是空

駆け出しエンジニアが学んだことをまとめていくブログ

bundle installでrmagicが入らない時の対処法

マジシャン

環境メモ

エラーの原因

rmagic(2.15.4)がImageMagic7系に対応していない

$ gem install rmagick -v '2.15.4'  
                                                                                                                                                                 
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.0/bin/ruby -r ./siteconf20200327-32437-xgc1bd.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 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.15.4. 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/username/.rbenv/versions/2.2.0/bin/$(RUBY_BASE_NAME)
extconf failed, exit code 1
Gem files will remain installed in /Users/username/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rmagick-2.15.4 for inspection.
Results logged to /Users/username/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-18/2.2.0-static/rmagick-2.15.4/gem_make.out

上記のようなエラーが出たら、自身の環境にあるImageMagickのversionを確認。

$ brew list 

# -略-
imagemagick
# -略-

ImageMagickが7系しかないことが確認できたら、今回の対処法で解決する(多分)。自分は解決しました。

対処法

imagemagick@6を入れる

$ brew install imagemagick@6

7系のリンクを解除して6系に繋ぎ直す

$ brew unlink imagemagick
$ brew brew link imagemagick@6 --force

再度インストール

$ gem install rmagick -v '2.15.4'
Building native extensions.  This could take a while...
Successfully installed rmagick-2.15.4
1 gem installed             

Congratulations !

今回のオススメ漫画

  • スローライフ
  • 男らしくて女の子に人気の女子
  • 白髪長髪の和やか男子

いずれかが好きな方、絶対好きです!私はすべて好きです。ツボ。 穏やかでほっこりした気分になる漫画です。