Ubuntu - 无法安装RMagick

10
如何在Ubuntu上安装RMagick gem?我在这里找到了一些帖子,其中一些直接指出了在Ubuntu系统上的安装方法,但是它们都对我不起作用。
如果我运行sudo gem install rmagick,下面是我得到的输出。
Building native extensions.  This could take a while...
ERROR:  Error installing rmagick:
    ERROR: Failed to build gem native extension.

        /opt/bitnami/ruby/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for gcc... yes
checking for Magick-config... yes

Warning: Found more than one ImageMagick installation. This could cause problems at runtime.
         /opt/bitnami/common/bin/Magick-config reports version 6.7.5 Q16 is installed in /opt/bitnami/common
         /usr/bin/Magick-config reports version 6.6.9 Q16 is installed in /usr
Using 6.7.5 Q16 from /opt/bitnami/common.

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.2. 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=/opt/bitnami/ruby/bin/ruby


Gem files will remain installed in /opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rmagick-2.13.2 for inspection.
Results logged to /opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rmagick-2.13.2/ext/RMagick/gem_make.out

它在亚马逊的EC2服务器上。 如果我尝试运行只有gem install rmagick,我会得到:
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions into the /opt/bitnami/ruby/lib/ruby/gems/1.9.1 directory.

“请问您能帮我解决这个问题吗?谢谢。”
“附注:我尝试过以下方法:”
  1. sudo apt-get install libmagickwand-dev

    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    libmagickwand-dev is already the newest version.
    The following packages were automatically installed and are no longer required:
      libgraphicsmagick3 libmagick++4 libgraphicsmagick++3 libgraphicsmagick1-dev
      libgraphics-magick-perl libperl5.14 libgraphicsmagick++1-dev
    Use 'apt-get autoremove' to remove them.
    0 upgraded, 0 newly installed, 0 to remove and 40 not upgraded.
    
  2. sudo apt-get install libmagickwand-dev imagemagick

    Reading package lists... Done Building dependency tree Reading state information... Done imagemagick is already the newest version. libmagickwand-dev is already the newest version. The following packages were automatically installed and are no longer required: libgraphicsmagick3 libmagick++4 libgraphicsmagick++3 libgraphicsmagick1-dev libgraphics-magick-perl libperl5.14 libgraphicsmagick++1-dev Use 'apt-get autoremove' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 40 not upgraded.

  3. apt-get install libmagickwand-dev

    E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied) E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?

  4. sudo apt-get install libmagickwand-dev

    Reading package lists... Done Building dependency tree Reading state information... Done libmagickwand-dev is already the newest version. The following packages were automatically installed and are no longer required: libgraphicsmagick3 libmagick++4 libgraphicsmagick++3 libgraphicsmagick1-dev libgraphics-magick-perl libperl5.14 libgraphicsmagick++1-dev Use 'apt-get autoremove' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 40 not upgraded.

但仍然出现了相同的错误信息。

已经有一个关于此问题的超级用户问答了http://superuser.com/questions/163818/how-to-install-rmagick-on-ubuntu-10-04 - mdesantis
请查看原帖更新。 - user984621
我几天前使用了Bitnami实例,而且我不需要安装rmagick,你需要更新版本吗?你可以尝试在Gemfile中设置与实例相同的版本gem 'rmagick','实例中的版本'。我想你可以通过rmagick -v命令获取实例中的版本。 - sites
@juanpastas 如果我在控制台中运行 rmagick -v,我会得到 `抱歉,command-not-found 已崩溃!请在以下网址上提交错误报告: https://bugs.launchpad.net/command-not-found/+filebug 请在报告中包含以下信息:command-not-found 版本:0.2.44` - user984621
尝试以下命令:sudo apt-get install imagemagick libmagickwand-dev然后执行:bundle - rusllonrails
显示剩余2条评论
1个回答

35

从错误输出来看,你缺少rmagick的一个依赖项。请尝试使用如下命令:

sudo apt-get install libmagickwand-dev

然后再执行以下命令:

gem install rmagick

第二个问题可能是由于权限问题引起的。提供更多有关你所执行的步骤的信息将有助于我们为你提供更好的答案。


你好,我尝试了这个命令(第三个小圆点)。我不确定权限是否正确,有没有类似于“权限重置”的东西? - user984621
https://dev59.com/PHHYa4cB1Zd3GeqPHyBa#17212105 - webster
1
或者只需在其前面添加 sudo :) - Ciprian Tomoiagă
你真棒! - Nezir

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