![服务器更新后无法安装 rmagick](https://linux22.com/image/650597/%E6%9C%8D%E5%8A%A1%E5%99%A8%E6%9B%B4%E6%96%B0%E5%90%8E%E6%97%A0%E6%B3%95%E5%AE%89%E8%A3%85%20rmagick.png)
我正在运行 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-compat
安装并单独安装后libmagickcore-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.
答案1
问题很简单。您的系统上任何地方都找不到 Magick-config。当您卸载 imagemagick 时,它也被卸载了 - 显然您没有再次使用 imagemagick 安装它。要解决此问题,请安装以下软件包:
sudo apt-get install libmagick++-dev graphicsmagick-libmagick-dev-compat libmagickcore-dev
然后重新运行 gem 安装程序。
答案2
对于将来遇到此问题的人:我花了很长时间才解决。这是我所做的:
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
答案3
可能是您正在安装 ImageMagick 版本 7.xx,它会在您的usr/lib/local/include/ImageMagick7.x.x
文件夹中生成不同的文件夹名称。
在 ImageMagick6.xx 版本中,我们有magick
,wand
命名的文件夹,而在 ImageMagick7.xx 版本中,这个文件夹被命名为MagickCore
,MagickWand
。因此,此更新会导致某些 gem 安装出现问题,例如此处。使用
magick/some_header.h
或wand/some_header.h
(意味着它们没有使用新的 7.xx ImageMagick 版本进行更新)。
这就是我们收到此错误的原因:
```
checking for outdated ImageMagick version (<= 6.4.9)... no
checking for presence of MagickWand API (ImageMagick version >= 6.9.0)... no
....
checking for wand/MagickWand.h... no
```
在日志文件中类似这样的内容:
error: 'MagickCore/method-attribute.h' file not found
#include "MagickCore/method-attribute.h"
^
解决方案
从官方网站在您的系统中安装 ImageMagick6.xx 版本:https://www.imagemagick.org/download/并使用以下命令进行安装(解压 zip/tar 后):
./configure
make
make install
然后做
gem install rmagick
它会起作用的。