Ruby-on-Rails

伺服器更新後無法安裝 rmagick

  • January 24, 2017

我正在執行一個 debian 伺服器並在一段時間後升級了所有軟體包(apt-get update, apt-get upgrade, apt-get distro-upgrade)。然後 rmagick 不再工作,因為 imagemagick 已更新。

所以我跑了:

gem uninstall rmagick
bundle install

然後我得到了這個:

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

   /usr/local/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for gcc... yes
checking for Magick-config... no
Can't install RMagick 0.0.0. Can't find Magick-config in /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

*** 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/local/bin/ruby

extconf failed, exit code 1

Gem files will remain installed in /srv/www/www.example.com/shared/vendor/bundle/ruby/2.1.0/gems/rmagick-2.13.3 for inspection.
Results logged to /srv/www/www.example.com/shared/vendor/bundle/ruby/2.1.0/extensions/x86_64-linux/2.1.0-static/rmagick-2.13.3/gem_make.out
An error occurred while installing rmagick (2.13.3), and Bundler cannot continue.
Make sure that `gem install rmagick -v '2.13.3'` succeeds before bundling.

這是cat mkmf.log

   checking for Ruby version >= 1.8.5... -------------------- yes

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

find_executable: checking for gcc... -------------------- yes

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

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

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

Can't install RMagick 0.0.0. Can't find Magick-config in /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

誰能幫我這個?

— 更新 1 —

在安裝了一些 graphicsmagic 的東西之後,我得到了一些進一步的資訊:

apt-get install graphicsmagick-libmagick-dev-compat
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
 libmagick++-6-headers libmagick++-6.q16-dev
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
 libmagick++-dev libmagickcore-dev
The following NEW packages will be installed:
 graphicsmagick-libmagick-dev-compat
0 upgraded, 1 newly installed, 2 to remove and 1 not upgraded.
Need to get 0 B/26.2 kB of archives.
After this operation, 267 kB disk space will be freed.
Do you want to continue? [Y/n]

這是bundle install輸出:

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 stdint.h... yes
checking for sys/types.h... yes
checking for wand/MagickWand.h... no

Can't install RMagick 0.0.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=/usr/local/bin/ruby

extconf failed, exit code 1

這對我們有任何幫助嗎?

*** — 更新 2 — ***

單獨安裝後graphicsmagick-libmagick-dev-compatlibmagickcore-dev我嘗試安裝libmagick++-dev

apt-get install libmagick++-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
 graphicsmagick-libmagick-dev-compat
The following NEW packages will be installed:
 libmagick++-dev
0 upgraded, 1 newly installed, 1 to remove and 1 not upgraded.
Need to get 0 B/121 kB of archives.
After this operation, 115 kB of additional disk space will be used.

對於將來遇到此問題的人:我花了很長時間,但已解決。這就是我所做的:

sudo apt-get purge imagemagick libmagickcore-dev libmagickwand-dev
sudo rm -R /usr/include/ImageMagick-6/magick
sudo ln -s /usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9/bin-Q16/Magick-config /usr/bin/Magick-config
sudo apt-get install imagemagick libmagickcore-dev libmagickwand-dev

問題很簡單。在您的系統上的任何地方都找不到 Magick-config。當您解除安裝 imagemagick 時,它也被解除安裝了 - 顯然您沒有再次使用 imagemagick 安裝它。要解決此問題,請安裝以下軟體包:

sudo apt-get install libmagick++-dev graphicsmagick-libmagick-dev-compat libmagickcore-dev

然後重新執行 gem 安裝過程。

引用自:https://serverfault.com/questions/662733