ruby-on-rails - 无法安装旧版本的 gem "rmagick"

标签 ruby-on-rails ruby linux ruby-on-rails-3

我碰巧有一个有点老的 rails 项目,它是 rails 3.2 和 ruby​​ 2.2.4。因此,安装一些 gem 会失败,尤其是“rmagick -v '2.13.2'”。

    $ gem install rmagick -v '2.13.2'
    Building native extensions.  This could take a while...
    ERROR:  Error installing rmagick:
            ERROR: Failed to build gem native extension.

        /home/user123/.rubies/ruby-2.2.4/bin/ruby -r ./siteconf20160826-3014-1j0i394.rb extconf.rb
    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 HDRI disabled version of ImageMagick... no

    Can't install RMagick 2.13.2.
    RMagick does not work when ImageMagick is configured for High Dynamic Range Images.
    Don't use the --enable-hdri option when configuring ImageMagick.

    *** 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=/home/user123/.rubies/ruby-2.2.4/bin/$(RUBY_BASE_NAME)

    extconf failed, exit code 1

    Gem files will remain installed in /home/user123/.gem/ruby/2.2.4/gems/rmagick-2.13.2 for inspection.
    Results logged to /home/user123/.gem/ruby/2.2.4/extensions/x86_64-linux/2.2.0-static/rmagick-2.13.2/gem_make.out

我已经尝试卸载库“ImageMagick”并安装一个没有 hdri 的库,但即使这样也失败了,因为还有其他依赖于“ImageMagick”和 hdri 的库,因此我无法重新安装它。 通常,仅为单个 Rails 项目重新安装库听起来不是正确的做法。

那你会推荐我什么? 我在 Arch Linux 上并安装了 2 个 ruby :

$ chruby
 * ruby-2.2.4
   ruby-2.3.1

也许我应该将它升级到更新的版本?请注意,我不想破坏项目中的其他依赖项。

最佳答案

您可以在其他位置安装非 HDRI 库,并通过执行以下操作确保首先找到其 Magick-config:

PATH="/alternative-path-you-choose/ImageMagick-6.8.9/bin-Q16:$PATH" gem install rmagick -v '2.13.2'

关于ruby-on-rails - 无法安装旧版本的 gem "rmagick",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39165704/

相关文章:

ruby-on-rails - 从mysql导入夹具数据

ruby-on-rails - 如何在带有自定义标签的表单中使用 Cucumber

ruby-on-rails - rails 不再生成脚本/服务器

python - 从 python 脚本中将参数传递给 x-executable 文件

ruby-on-rails - 状态机、模型验证和 RSpec

javascript - 在 Ruby on Rails 的 View 中加载 JavaScript

ruby - 迭代字符串数组并执行正则表达式

ruby - 使用 Lucene Parser 和 Solr 使用 Sunspot 进行多字段搜索

linux - 如果 mmap() 没有 fd(使用 MAP_ANONYMOUS),将调用哪个函数?

php - 使用 Zend Framework 2 和 ODBC 驱动程序连接忙于 Linux 上的 MS SQL Server