【问题标题】:How to resolve gem dependencies when installing rbenv?安装rbenv时如何解决gem依赖?
【发布时间】:2018-05-10 11:23:43
【问题描述】:

最近我安装了 rbenv 并将 ruby​​ 指定为 2.3.1 并将 rails 指定为 5.1.1 但我无法运行我的项目,因为我得到了:

Ignoring json-2.1.0 because its extensions are not built.  Try: gem pristine json --version 2.1.0
Ignoring nokogiri-1.8.1 because its extensions are not built.  Try: gem pristine nokogiri --version 1.8.1
Ignoring unf_ext-0.0.7.4 because its extensions are not built.  Try: gem pristine unf_ext --version 0.0.7.4
Ignoring yajl-ruby-1.3.1 because its extensions are not built.  Try: gem pristine yajl-ruby --version 1.3.1
/var/lib/gems/2.3.0/gems/bundler-1.16.1/lib/bundler/spec_set.rb:88:in `block in materialize': Could not find unf_ext-0.0.7.4 in any of the sources (Bundler::GemNotFound)

from /var/lib/gems/2.3.0/gems/bundler-1.16.1/lib/bundler/spec_set.rb:82:in `map!'
...
from /home/alex/pnv/vendor/bundle/ruby/2.3.0/gems/spring-2.0.2/bin/spring:49:in `<main>'

我跑了:

bundle install

安装成功,但是...现在我得到:

/home/alex/pnv/vendor/bundle/ruby/2.3.0/gems/ffi-1.9.18/lib/ffi.rb:6:in `require': incompatible library version - /home/alex/pnv/vendor/bundle/ruby/2.3.0/gems/ffi-1.9.18/lib/ffi_c.so (LoadError)
    from /home/alex/pnv/vendor/bundle/ruby/2.3.0/gems/ffi-1.9.18/lib/ffi.rb:6:in `rescue in <top (required)>'
    from /home/alex/pnv/vendor/bundle/ruby/2.3.0/gems/ffi-1.9.18/lib/ffi.rb:3:in `<top (required)>'
    from /home/alex/pnv/vendor/bundle/ruby/2.3.0/gems/rb-inotify-0.9.8/lib/rb-inotify/native.rb:1:in `require'
    from /home/alex/pnv/vendor/bundle/ruby/2.3.0/gems/rb-inotify-0.9.8/lib/rb-inotify/native.rb:1:in `<top (required)>'
    from /home/alex/pnv/vendor/bundle/ruby/2.3.0/gems/rb-inotify-0.9.8/lib/rb-inotify.rb:1:in `require'
    from /home/alex/pnv/vendor/bundle/ruby/2.3.0/gems/rb-inotify-0.9.8/lib/rb-inotify.rb:1:in `<top (required)>'
    from /home/alex/pnv/vendor/bundle/ruby/2.3.0/gems/listen-3.0.8/lib
    ...
    from /home/alex/.rbenv/versions/2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:59:in `require'
    from -e:1:in `<main>'

我不知道如何解决这个问题。任何帮助表示赞赏!

更新 1: 最后,我找到了这个邪恶错误的来源——尽管如此,我指定 Rails 5.1.1,当我运行 rails new app_name 时,它​​会安装 5.1.6!似乎它使用 5.1.6 gem 依赖项......仍然不知道如何解决而不是升级到 >= 5.1.6

【问题讨论】:

  • 在这种情况下,在您的 Gemfile 中添加行 gem rails, '5.1.1'
  • @AkashPinnaka 谢谢,就是这样!我必须指定版本!请修改您的答案,以便我接受!
  • 更新了答案@AlexanderGorg

标签: ruby-on-rails bundler rbenv


【解决方案1】:

将以下行添加到您的 Gemfile。

gem 'rails', '5.1.1'

运行bundle install

【讨论】:

  • 你能再试试bundle uninstall ffibundle install吗?
  • 如果你得到'找不到命令卸载',似乎你不小心跳过了bundle。尝试bundle uninstall ffi 而不是uninstall ffi。下次你可以试试。但很高兴听到您的问题得到解决:)。 @AlexanderGorg
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-09-20
  • 2012-10-12
  • 1970-01-01
  • 2013-07-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多