replace_gem: Error loading the 'sqlite3' Active Record adapter - while creating model

穿精又带淫゛_ 提交于 2019-12-17 18:53:08

问题


I am getting an error while creating a model in the created project and the error is as follows,

/home/sushmitha/.rvm/gems/ruby-2.5.1/gems/bundler-2.0.1/lib/bundler/rubygems_integration.rb:408:in `block (2 levels) in replace_gem': Error loading the 'sqlite3' Active Record adapter. Missing a gem it depends on? can't activate sqlite3 (~> 1.3.6), already activated sqlite3-1.4.0. Make sure all dependencies are added to Gemfile. (LoadError)


回答1:


For reference only following is added here,

For Rails 5+, this issue is sort out by specifying the appropriate version for the sqlite gem in your Gemfile while working with an SQLite database:

 gem 'sqlite3', '~> 1.3', '>= 1.3.6'

Reference




回答2:


For rails 5.2.2 explicitly , update your Gemfile to sqlite to:

gem 'sqlite3', '~> 1.3.6'

and in terminal use :

bundle update



回答3:


I have placed gem 'sqlite3', '~> 1.3.6' inside of group :deevelopment, :test do and it worked for me.

e.g :

group :development, :test do
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  gem 'sqlite3', '~> 1.3.6'
end



回答4:


Now that rails 5.2.2.1 has been released, the correct and also easiest fix is to bump rails to that version, as it will restrict sqlite3 to 1.3.6:

# In Gemfile
gem 'rails', '~> 5.2.2.1'

And then in the terminal

bundle install

Given the security fixes in that version, this should be done anyway.



来源:https://stackoverflow.com/questions/54529739/replace-gem-error-loading-the-sqlite3-active-record-adapter-while-creating

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!