安装rbenv时如何解决gem依赖关系?

时间:2018-05-10 11:23:43

标签: ruby-on-rails bundler rbenv

最近我已经安装了rbenv并指定了ruby到2.3.1并且导航到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 : 最后,我找到了邪恶的bug的来源 - 尽管如此,我指定了Rails 5.1.1,当我运行rails new app_name时,它会安装5.1.6!并且似乎它使用5.1.6 gem依赖...仍然不知道如何解决而不是升级到&gt; = 5.1.6

1 个答案:

答案 0 :(得分:1)

将以下行添加到Gemfile中。

gem 'rails', '5.1.1'

运行bundle install