错误:rails

时间:2016-05-01 04:22:54

标签: ruby-on-rails ruby ruby-on-rails-3 sqlite sqlite3-ruby

我在使用Ubuntu系统(16.04)。

我的问题是每当我设置任何rails项目并尝试运行rails s然后我的sqlite3出现'不兼容的库版本'错误,如下所示。

/home/jiggs/.rvm/gems/ruby-2.3.1@albumriver/gems/activesupport-4.0.0/lib/active_support/values/time_zone.rb:282: warning: circular argument reference - now
/home/jiggs/.rvm/gems/ruby-2.3.1@albumriver/gems/sqlite3-1.3.11/lib/sqlite3.rb:6:in `require': incompatible library version - /home/jiggs/.rvm/gems/ruby-2.3.1@albumriver/gems/sqlite3-1.3.11/lib/sqlite3/sqlite3_native.so (LoadError)
    from /home/jiggs/.rvm/gems/ruby-2.3.1@albumriver/gems/sqlite3-1.3.11/lib/sqlite3.rb:6:in `rescue in <top (required)>'
    from /home/jiggs/.rvm/gems/ruby-2.3.1@albumriver/gems/sqlite3-1.3.11/lib/sqlite3.rb:2:in `<top (required)>'
    from /usr/lib/ruby/vendor_ruby/bundler/runtime.rb:77:in `require'
    from /usr/lib/ruby/vendor_ruby/bundler/runtime.rb:77:in `block (2 levels) in require'
    from /usr/lib/ruby/vendor_ruby/bundler/runtime.rb:72:in `each'
    from /usr/lib/ruby/vendor_ruby/bundler/runtime.rb:72:in `block in require'
    from /usr/lib/ruby/vendor_ruby/bundler/runtime.rb:61:in `each'
    from /usr/lib/ruby/vendor_ruby/bundler/runtime.rb:61:in `require'
    from /usr/lib/ruby/vendor_ruby/bundler.rb:99:in `require'
    from /home/jiggs/sites/albumriverfinal/config/application.rb:7:in `<top (required)>'
    from /home/jiggs/.rvm/gems/ruby-2.3.1@albumriver/gems/railties-4.0.0/lib/rails/commands.rb:76:in `require'
    from /home/jiggs/.rvm/gems/ruby-2.3.1@albumriver/gems/railties-4.0.0/lib/rails/commands.rb:76:in `block in <top (required)>'
    from /home/jiggs/.rvm/gems/ruby-2.3.1@albumriver/gems/railties-4.0.0/lib/rails/commands.rb:73:in `tap'
    from /home/jiggs/.rvm/gems/ruby-2.3.1@albumriver/gems/railties-4.0.0/lib/rails/commands.rb:73:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

Rails版本:4.0.0

ruby​​版本我尝试使用rails 4.0.0:

  • ruby​​-2.0.0-p247 [x86_64]

  • ruby​​-2.2.5 [x86_64]

  • ruby​​-2.3.0 [x86_64]

  • ruby​​-2.3.0-preview1 [x86_64]

  • ruby​​-2.3.1 [x86_64]

我尝试使用gem uninstall sqlite3卸载sqlite3并尝试运行bundle install但出现此错误:

An error occurred while installing sqlite3 (1.3.11), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.3.11'` succeeds before bundling.

然后我运行gem install sqlite3 -v '1.3.11'并运行rails server并再次遇到同样的错误incompatible library version

输出sqlite3 gem install

gem install sqlite3 -v '1.3.11'
Fetching: sqlite3-1.3.11.gem (100%)
Building native extensions.  This could take a while...
Successfully installed sqlite3-1.3.11
Parsing documentation for sqlite3-1.3.11
Installing ri documentation for sqlite3-1.3.11
Done installing documentation for sqlite3 after 1 seconds
1 gem installed

5 个答案:

答案 0 :(得分:10)

SQLite库可能已损坏。尝试通过命令pronpt:

运行以下命令重新安装gem
gem uninstall sqlite3

然后运行:

bundle install

答案 1 :(得分:1)

我已将ruby版本回滚到2.3.0并且全部工作。这似乎是一个问题

答案 2 :(得分:1)

@Jiggs:我的系统更新到16.04时遇到的问题。之后所有以前的应用程序都难以配置为抛出如此多的依赖性错误,其中您的错误就是其中之一。

经过大量的发现后,我得到的问题是RVM,

如果您使用的是RVM,请在您的default gemset

中安装Rails 5.0
rvm gemset use default
gem install rails -v=5.0 

安装rails 5后,将安装所有兼容的依赖项。

现在转到您的任何项目CREATE New GEMSET(请不要使用之前的)。

rvm gemset create my_new_gemset
rvm gemset use my_new_gemset

最后做bundle install

在我这样做之后,解决了你提到的所有错误。

我知道在默认gemset中安装Rails-5并使用新的gemset解决此问题有点奇怪。但它不知何故有效。

希望这会对你有所帮助。

答案 3 :(得分:0)

对于我回到红宝石2.2.5p319帮助。我只是意识到Rails附带的Ruby版本必须与安装的版本匹配,即使RubyInstaller版本已经发布。

答案 4 :(得分:0)

我来到这里寻找答案,没有帮助我,但我找到了解决方案here,(似乎是1.3.11的问题,降级到1.3.10就可以了)