Ubuntu 12.10 - Ruby gem rmagick 缺少依赖问题

4
像很多人一样,当我运行bundle install时,在Ubuntu上安装rmagick遇到了问题。
我在运行bundle install命令时遇到以下错误:
Installing rmagick (2.13.1) 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /usr/local/rvm/rubies/ruby-1.8.7-p371/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 2.13.1. Can't find Magick-config in /usr/local/rvm/gems/ruby-1.8.7-p371/bin:/usr/local/rvm/gems/ruby-1.8.7-p371@global/bin:/usr/local/rvm/rubies/ruby-1.8.7-p371/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/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/rvm/rubies/ruby-1.8.7-p371/bin/ruby


Gem files will remain installed in /home/selfsale/.bundler/tmp/2908/gems/rmagick-2.13.1 for inspection.
Results logged to /home/selfsale/.bundler/tmp/2908/gems/rmagick-2.13.1/ext/RMagick/gem_make.out

An error occurred while installing rmagick (2.13.1), and Bundler cannot continue.
Make sure that `gem install rmagick -v '2.13.1'` succeeds before bundling.

我随后进行了一些搜索,并找到了一些添加缺失库的建议:
sudo apt-get install libmagick9-dev:
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package libmagick9-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  graphicsmagick-libmagick-dev-compat

E: Package 'libmagick9-dev' has no installation candidate

请执行sudo apt-get install graphicsmagick-libmagick-dev-compat命令以安装相关的IT技术。

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 graphicsmagick-libmagick-dev-compat : Depends: libgraphicsmagick1-dev but it is not going to be installed
                                       Depends: libgraphicsmagick++1-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

sudo apt-get install libmagickwand-dev:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libmagickwand-dev : Depends: libmagickcore-dev (= 8:6.6.9.7-5ubuntu3.2) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

sudo apt-get install libmagickcore-dev:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libmagickcore-dev : Depends: libbz2-dev but it is not going to be installed
                     Depends: libfreetype6-dev but it is not going to be installed
                     Depends: libpng-dev
                     Depends: librsvg2-dev but it is not going to be installed
                     Depends: libwmf-dev but it is not going to be installed
                     Depends: libx11-dev but it is not going to be installed
                     Depends: libxext-dev but it is not going to be installed
                     Depends: libxt-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

sudo apt-get install libmagick++-dev:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libmagick++-dev : Depends: libmagickcore-dev (= 8:6.6.9.7-5ubuntu3.2) but it is not going to be installed
                   Depends: libmagickwand-dev (= 8:6.6.9.7-5ubuntu3.2) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

看起来任何尝试安装正确软件包的尝试都会出现这个问题。

我刚刚看到一篇有关从源代码安装Imagemagick的帖子,所以我将尝试这样做,但如果有更好的建议,我很乐意听取。

谢谢。


它不会直接解决你的问题,但是一旦你在bundle install中遇到问题,回退到针对特定问题gem的gem install是值得的。这样稍微快一些,并且有时候表现出足够不同的行为,可以给你更好的问题线索。一旦解决了,你就可以再次回到bundle install来进行你的项目。 - Neil Slater
5个回答

9
我找到了解决方案:
sudo apt-get install aptitude

然后触发:
sudo aptitude install graphicsmagick-libmagick-dev-compat

当被问及:

The following actions will resolve these dependencies:
 Keep the following packages at their current version
1)     graphicsmagick-libmagick-dev-compat [Not Installed]
2)     libexif-dev [Not Installed]
3)     libgraphicsmagick++1-dev [Not Installed]
4)     libgraphicsmagick1-dev [Not Installed]

答案是:"n"。
Accept this solution? [Y/n/q/?] n

在第二个问题中:
The following actions will resolve these dependencies:

 Downgrade the following packages: 
1) libexif12 [0.6.20-2ubuntu0.1 (now) -> 0.6.20-2 (precise)] 

答案:输入"Y"或按下回车键。
Accept this solution? [Y/n/q/?]

等待任务结束 :)


8

我刚刚在我的笔记本电脑上尝试了一下(Ubuntu 13.04)。

gem install rmagick

同样失败了。然后我进行了

sudo apt-get install libmagick++-dev

并且 rmagick 已经成功安装。


感谢你尝试帮助我,Philipp,但不幸的是,这也导致了依赖错误。我会将其添加到列表中。 - eb_dev
@eb_dev:我在Ubuntu 12.10系统(服务器版本,无GUI)和Ruby 1.8.7-p371上成功复制了OP中的原始故障,然后为我执行了sudo apt-get install libmagick++-dev和rmagick安装。如果您已经有一段时间没有更新了,我认为在sudo apt-get update之后再次尝试是值得的... - Neil Slater
好的。我无法重现这个问题。但是请看一下这个askubuntu页面:http://askubuntu.com/questions/140246/how-do-i-resolve-unmet-dependencies它提供了许多可能的解决方案来解决未满足依赖关系的问题。 - tessi
@PhilippTessenow 谢谢Neil,我已经到了清除PPA的步骤,现在时间不够了,所以我想我不得不付钱请别人帮忙。等他们有了解决方案我会再发帖的。 - eb_dev

5
这个解决方案比之前展示的更为重要,因为它移除了:graphicsmagick-libmagick-dev-compat,同时解决了在“bundle install”中出现的问题。
checking for wand/MagickWand.h... no

如我在第二篇帖子中所示,在提示中键入:
sudo aptitude install libmagickwand-dev

在:

The following actions will resolve these dependencies:

  Keep the following packages at their current version
1)      libatk1.0-dev [Not Installed]
2)      libcairo2-dev [Not Installed]
3)      libexpat1-dev [Not Installed]
4)      libgdk-pixbuf2.0-dev [Not Installed]
5)      libglib2.0-dev [Not Installed]
6)      libgraphviz-dev [Not Installed]
7)      libgtk2.0-dev [Not Installed]
8)      libmagickcore-dev [Not Installed]
9)      libmagickwand-dev [Not Installed]
10)     libpango1.0-dev [Not Installed]
11)     librsvg2-dev [Not Installed]

答案:
Accept this solution? [Y/n/q/?] n

在第二步:

以下操作将解决这些依赖关系:

  Remove the following packages: 
1 ) graphicsmagick-libmagick-dev-compat
Install the following packages:
2)libcairo-script-interpreter2 [1.10.2-6.1ubuntu2 (precise)]
[..]

答案:“是”
Accept this solution? [Y/n/q/?]

完成任务后,您可以轻松在项目目录中运行'bundle install'

3
尝试一起安装imagemagick和libmagickwand-dev:
sudo apt-get install imagemagick libmagickwand-dev

这能使apt正确解决依赖关系。(在Ubuntu 12.04上测试过)


0
sudo apt-get install libmagick++-dev

rmagick 安装成功


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接