【问题标题】:Ruby on Rails RMagick gem install issueRuby on Rails RMagick gem 安装问题
【发布时间】:2013-10-02 03:04:35
【问题描述】:

(编辑:解决方案见底部)我正在制作一个 Ruby On Rails 项目并尝试安装 RMagick gem。使用 OS X 10.6、Ruby 版本 2.0.0p247、Rails 4.0.0、RVM 1.22.12。

当我运行捆绑安装时,我收到以下错误:

...
Installing rmagick (2.13.2) 
Errno::EACCES: Permission denied - /Users/jasonpather/.rvm/gems/ruby-2.0.0-p247/g
ems/rmagick-2.13.2/build_tarball.rake
An error occurred while installing rmagick (2.13.2), and Bundler cannot continue.
Make sure that `gem install rmagick -v '2.13.2'` succeeds before bundling.

那么我试试这个建议:

Jason-Pathers-MacBook-Pro:BuyABrick jasonpather$ gem install rmagick -v '2.13.2'
ERROR:  While executing gem ... (Errno::EACCES)
Permission denied - /Users/jasonpather/.rvm/gems/ruby-2.0.0-p247/gems/rmagick
-2.13.2/build_tarball.rake

然后我尝试 sudo:

Jason-Pathers-MacBook-Pro:BuyABrick jasonpather$ sudo gem install rmagick -v '2.1
3.2'
Password:
Building native extensions.  This could take a while...
ERROR:  Error installing rmagick:
    ERROR: Failed to build gem native extension.

/Users/jasonpather/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for gcc-4.2... yes
checking for Magick-config... no
Can't install RMagick 2.13.2. Can't find Magick-config in /Users/jasonpather/.rvm
/gems/ruby-2.0.0-p247/bin:/Users/jasonpather/.rvm/gems/ruby-2.0.0-p247@global/bin
:/Users/jasonpather/.rvm/rubies/ruby-2.0.0-p247/bin:/Users/jasonpather/.rvm/gems/
ruby-2.0.0-p247/bin:/Users/jasonpather/.rvm/gems/ruby-2.0.0-p247@global/bin:/User
s/jasonpather/.rvm/rubies/ruby-2.0.0-p247/bin:/Users/jasonpather/.rvm/bin:/opt/lo
cal/bin:/opt/local/sbin:/opt/local/lib/postgresql83/bin/:/usr/local/bin:/usr/bin:
/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/texbin:/usr/X11/bin

*** 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
    --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/jasonpather/.rvm/rubies/ruby-2.0.0-p247/bin/ruby


Gem files will remain installed in /Users/jasonpather/.rvm/gems/ruby-2.0.0-p247/g
ems/rmagick-2.13.2 for inspection.
Results logged to /Users/jasonpather/.rvm/gems/ruby-2.0.0-p247/gems/rmagick-2.13.
2/ext/RMagick/gem_make.out

我将非常感谢任何帮助。我在这个网站上看过类似的问题,但没有任何建议有帮助。在安装 RMagick 之前是否需要安装其他软件包?

编辑:解决方案

我只是使用自制软件安装了 imagemagick brew install imagemagick 然后 sudo gem install rmagick 现在 bundle install 运行良好!

【问题讨论】:

  • 这个问题的建议不起作用? *.com/q/3704919/1004046
  • 首先安装ImageMagic。如何:imagemagick.org/script/binary-releases.php#macosx
  • @YevgeniyAnfilofyev 我现在正在尝试,我按照该页面上的说明进行操作,但是当我尝试运行convert logo: logo.gif 时,它告诉我“非法指令”和bundle install 会抛出相同的错误。您链接的方法是否适用于 Snow Leopard 10.6,即使它在描述中显示为 Mountain Lion?编辑:根据this,二进制文件是 Lion-only :(
  • Illegal instruction 可能意味着您执行了错误的二进制文件。你是从port 还是通过下载二进制文件安装的?我现在离开了我的 OS X,所以当我回到家时,我会检查 OS X 10.6 上 ImageMagic 的安装
  • @YevgeniyAnfilofyev 我放弃了那个二进制文件,因为我认为它只是 Lion。我使用 Homebrew 来安装 imagemagick,它似乎已经奏效了。感谢您的帮助!

标签: ruby-on-rails ruby gem rvm rmagick


【解决方案1】:

您需要安装 Image Magick(您的日志中的checking for Magick-config... no 建议这样做)。

最简单的方法是使用Homebrew(因为您使用的是 Mac)。安装 Homebrew(按照它在安装过程中提供的任何说明进行操作——它们并不多),然后运行:

brew install imagemagick

然后再次运行bundle install

【讨论】:

  • 是的,你是对的,我试过了,结果就是成功!然后我使用sudo gem install rmagick 然后bundle install 工作!