将Rails 4.2更新到5.0.0&sqlite3 gem将无法加载

时间:2019-02-10 21:37:37

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

运行rails server时,我会加载以下警告:

Gem::LoadError: Specified 'sqlite3' for database adapter, but the gem is not loaded. Add `gem 'sqlite3'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).

但是我的gemfile中有gem

 group :development do
   gem 'sqlite3'

是什么导致此错误?

使用滑轨的说明从此处https://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#upgrading-from-rails-4-2-to-rails-5-0

更新

3 个答案:

答案 0 :(得分:1)

删除了gem sqlite3(v 1.4.0)并安装了1.3.13版,并且可以正常工作

答案 1 :(得分:1)

gem cleanup sqlite3

bundle install

让Rails选择sqlite3的正确版本

答案 2 :(得分:0)

在AWS cloud9环境中存在相同的问题。您需要更改gemfile来读取gem'sqlite3','〜> 1.3.6',然后运行bundle update。是从“ can't activate sqlite3 (~> 1.3.6), already activated sqlite3-1.4.0”那里获得的