Install rmagick Issue

今天試著把 redmine 裝到 Heroku 上,遇到了一個問題,做下記錄:

我在照著 Redmine 官方指示 操作的時候,第一個遇到的問題是沒裝 pg,直接執行 gem install pg -v '0.18.1' 發生了錯誤,需要執行 brew updatebrew install postgresql 才能順利執行 gem install pg -v '0.18.1',接著則是安裝 rmagick 發生錯誤:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /Users/Mac/.rvm/rubies/ruby-2.1.2/bin/ruby -r ./siteconf20150319-41698-m580g2.rb 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
/usr/local/bin/Magick-config: line 41: pkg-config: command not found
/usr/local/bin/Magick-config: line 47: pkg-config: command not found
/usr/local/bin/Magick-config: line 50: pkg-config: command not found
/usr/local/bin/Magick-config: line 53: pkg-config: command not found
checking for stdint.h... yes
checking for sys/types.h... yes
checking for wand/MagickWand.h... no

Can't install RMagick 2.13.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/Mac/.rvm/rubies/ruby-2.1.2/bin/ruby

extconf failed, exit code 1

Gem files will remain installed in /Users/Mac/.rvm/gems/ruby-2.1.2/gems/rmagick-2.13.4 for inspection.
Results logged to /Users/Mac/.rvm/gems/ruby-2.1.2/extensions/x86_64-darwin-13/2.1.0-static/rmagick-2.13.4/gem_make.out
An error occurred while installing rmagick (2.13.4), and Bundler cannot continue.
Make sure that `gem install rmagick -v '2.13.4'` succeeds before bundling.

找了一些解法,只有 這個連結 解決問題 ,依序執行底下步驟即可:

$ brew remove imagemagick
$ brew install imagemagick
Make sure pkg-config is correctly linked:

$ brew uninstall pkg-config
$ brew install pkg-config
$ brew unlink pkg-config && brew link pkg-config

$ gem install rmagick