尝试加载gem'rmagick'时出错。 (捆扎机:: GemRequireError)

时间:2016-01-30 11:23:08

标签: ruby-on-rails ruby ruby-on-rails-4

rails s
/Users/harshamv/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:80:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'rmagick'. (Bundler::GemRequireError)
    from /Users/harshamv/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    from /Users/harshamv/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `each'
    from /Users/harshamv/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `block in require'
    from /Users/harshamv/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `each'
    from /Users/harshamv/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `require'
    from /Users/harshamv/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler.rb:99:in `require'
    from /Users/harshamv/Sites/platehopper/config/application.rb:7:in `<top (required)>'
    from /Users/harshamv/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:79:in `require'
    from /Users/harshamv/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:79:in `block in server'
    from /Users/harshamv/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:76:in `tap'
    from /Users/harshamv/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:76:in `server'
    from /Users/harshamv/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
    from /Users/harshamv/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.1.8/lib/rails/commands.rb:17:in `<top (required)>'
    from bin/rails:8:in `require'
    from bin/rails:8:in `<main>'

当我尝试运行rails服务器时出现上述错误

3 个答案:

答案 0 :(得分:13)

接受的答案已过期。我在Mac OSX(El Capitan)和ImageMagick(6.9.4)上遇到了这个问题。我通过恢复到旧版本的ImageMagick并重新安装rmagick来解决它,如下所示:

brew uninstall --force imagemagick

注意:我必须使用--force,因为安装了多个旧版本。如果您担心--force选项,也可以多次运行该命令。

brew tap homebrew/versions
brew install https://raw.githubusercontent.com/Homebrew/homebrew-versions/master/imagemagick-ruby186.rb
gem uninstall rmagick
gem install rmagick -v 2.15.0

答案 1 :(得分:2)

当我部署rails应用程序时,我遇到了同样的问题,这是我必须要解决的问题。

首先确保从项目中删除imageMagick,在终端中执行以下命令

brew uninstall imagemagick

如果您收到错误,我们会使用。

brew uninstall -f imagemagick

然后安装版本2.14.0,这是我找到的最后一个工作版。

gem install rmagick -v 2.14.0

确保在使用bundle update之前将版本号添加到Gemfile中,如果遇到错误,请删除Gemfile.lock,这样bundle就可以重置任何奇怪的依赖项。

gem 'rmagick', '2.14.0'

如果我是对的,它应该再次运作。

答案 2 :(得分:1)

我想,使用RMagick安装的ImageMagick版本不支持此link