我收到此错误:为数据库适配器指定'sqlite3',但未加载gem

问题描述 投票:0回答:2

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

rails s -p $PORT -b $IP 

我收到一个错误,告诉我,当我这样做时,我在gem文件中没有sqlite3。这只发生在我将代码推送到Heroku之后,现在它不再在控制台中运行了。

我已经尝试'捆绑安装'和'捆绑更新',我也试图通过运行'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
ruby-on-rails
2个回答
1
投票

(代表作者提问)。

我最终修复了它,发生的事情是Gemfile.lock中的版本是'sqlite3(1.4.0)'但我需要的版本是'sqlite3(1.3.13)'。我改变了版本并再次运行'rake db:migrate'和'rake db:seed',现在它正在运行。


0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.