Masahiro Okubo

新しいパソコンにしたらRmagick関連のエラー発生

新しいパソコンにしたらRmagick関連のエラー発生

新しいパソコンにしたらRmagick関連のエラーがまた出て来ました

最近Python、Javaらへんばっかだったのでrailsのエラーは精神的になんか来ます。。

こちらがエラー文


$  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.

    current directory: /Users/hiyashikyuri/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rmagick-2.16.0/ext/RMagick
/Users/hiyashikyuri/.rbenv/versions/2.3.1/bin/ruby -r ./siteconf20180315-30193-14x1r2g.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/hiyashikyuri/.rbenv/versions/2.3.1/bin/$(RUBY_BASE_NAME)

解決策

$ brew uninstall imagemagick
$ brew install imagemagick@6
$ brew link --force imagemagick@6
$ echo 'export PATH="/usr/local/opt/imagemagick@6/bin:$PATH"' >> ~/.bash_profile

$ sudo gem install rmagick -v 2.16.0
Password:
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 5 seconds
1 gem installed

で問題なく通りました!

参考にした記事

MacOS Sierra で gem install rmagick が失敗する
Ruby gem rmagick won’t install on Mac OS X


関連記事

copyright© 2016-2021 Masahiro Okubo