Mac OS安裝gem rmagick
阿新 • • 發佈:2018-11-01
首先,必須安裝ImageMagick
bower install ImageMagick
安裝gem rmagick的時候報錯
Building native extensions. This could take a while... ERROR: Error installing rmagick: ERROR: Failed to build gem native extension. /usr/bin/ruby extconf.rb checking for Ruby version >= 1.8.5... yes checking for gcc... yes checking for Magick-config... yes checking for ImageMagick version >= 6.4.9... yes checking for HDRI disabled version of ImageMagick... 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 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 stdint.h... yes checking for sys/types.h... yes checking for wand/MagickWand.h... no Can't install RMagick 2.13.1. 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=/usr/bin/ruby
解決方法:
ImageMagick一般路徑:
/usr/local/lib/pkgconfig/MagickCore.pc
如果不對,可以用mdfind
mdfind MagickCore.pc
找到pkgconfig的路徑:
/usr/local/lib/pkgconfig
安裝gem時設定路徑
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig gem install rmagick
也可以將PKG_CONFIG_PATH寫入profile
vi ~/.bash_profile PKG_CONFIG_PATH=/usr/local/lib/pkgconfig export PKG_CONFIG_PATH
儲存之後可以執行
gem install rmagick