Ruby on rails I';我得到这个错误:指定';sqlite3';用于数据库适配器,但未加载gem

Ruby on rails I';我得到这个错误:指定';sqlite3';用于数据库适配器,但未加载gem,ruby-on-rails,Ruby On Rails,我正在尝试使用以下命令在Cloud 9上运行Ruby on Rails应用程序: rails s -p $PORT -b $IP 我得到一个错误,告诉我当我在gem文件中有sqlite3时,我没有。这只发生在我将代码推送到Heroku之后,现在它不再在控制台中运行 我已经尝试过“bundle install”和“bundle update”,我也尝试过通过运行“gem install sqlite3”手动安装sqlite3,但这些都没有解决我的问题。我也开始一遍又一遍地重复所有步骤,看看这个

我正在尝试使用以下命令在Cloud 9上运行Ruby on Rails应用程序:

rails s -p $PORT -b $IP 
我得到一个错误,告诉我当我在gem文件中有sqlite3时,我没有。这只发生在我将代码推送到Heroku之后,现在它不再在控制台中运行

我已经尝试过“bundle install”和“bundle update”,我也尝试过通过运行“gem install sqlite3”手动安装sqlite3,但这些都没有解决我的问题。我也开始一遍又一遍地重复所有步骤,看看这个问题是否会再次出现,确实如此

source 'https://rubygems.org'

ruby '2.4.1'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.10'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use Haml as the templating library
gem 'haml'
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

gem 'themoviedb'

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'

  gem 'rspec-rails'
  gem 'guard-rspec'

  # Use sqlite3 as the database for Active Record
  gem 'sqlite3'

  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'

  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end

group :production do
  gem 'pg', '~> 0.21' # for Heroku deployment
  gem 'rails_12factor'
end
源代码'https://rubygems.org'
ruby“2.4.1”
#捆绑边缘Rails:gem'Rails',github'Rails/Rails'
gem“轨道”,“4.2.10”
#将SCS用于样式表
gem'sass-rails',“~>5.0”
#使用Uglifier作为JavaScript资产的压缩器
gem'uglifier','>=1.3.0'
#将CoffeeScript用于.coffee资产和视图
gem“咖啡轨”,“~>4.1.0”
#看https://github.com/rails/execjs#readme 获取更多受支持的运行时
#宝石“therubyracer”,平台::ruby
#使用Haml作为模板库
宝石“哈姆”
#使用jquery作为JavaScript库
gem'jqueryrails'
#Turbolinks使web应用程序中的以下链接更快。阅读更多:https://github.com/rails/turbolinks
gem“涡轮链接”
#轻松构建JSON API。阅读更多:https://github.com/rails/jbuilder
gem'jbuilder',“~>2.0”
#bundle exec rake doc:rails在doc/API下生成API。
gem'sdoc','~>0.4.0',组::doc
#使用ActiveModel具有\u安全\u密码
#gem'bcrypt',“~>3.1.7”
#使用Unicorn作为应用程序服务器
#宝石“独角兽”
#使用Capistrano进行部署
#gem“capistrano rails”,集团::开发
宝石“themoviedb”
小组:开发,:测试
#在代码中的任意位置调用“byebug”以停止执行并获得调试器控制台
宝石“比伯”
gem'rspec rails'
gem“guard rspec”
#使用sqlite3作为活动记录的数据库
gem'sqlite3'
#在异常页面上或通过在视图中使用访问IRB控制台
gem“web控制台”,“~>2.0”
#Spring通过让应用程序在后台运行来加速开发。阅读更多:https://github.com/rails/spring
宝石“春天”
结束
小组:生产部
gem'pg','~>0.21'#用于Heroku部署
gem“rails_12factor”
结束

您的应用程序可能正在Heroku上运行生产环境,但您的Gemfile仅在开发和测试组中包含sqlite3。将sqlite3移出组,使其在所有环境中都可用,然后重新部署。

(代表问题作者发布)


我最终修复了它,Gemfile.lock中的版本是'sqlite3(1.4.0'),但我需要的版本是'sqlite3(1.3.13')。我更改了版本并再次运行了“rake db:migrate”和“rake db:seed”,现在它可以正常工作了。

使用Rails 5的sqlite3版本>1.4.0有问题。在1.3.11或1.3.13版本的Gemfile中明确提到sqlite3版本。
(gem'sqlite3','~>1.3.11')

Hi Cristina。若要将此问题标记为已解决,请单击下面我的社区wiki答案上的勾选/复选标记,该答案从“(以问题作者的名义发布)”开始。或者,如果你想在这个问题上赢得潜在的选票,请将它粘贴到你自己的新答案中,并让我知道,这样我就可以删除CW版本。谢谢