我正在尝试使用以下命令在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
答案 0 :(得分:1)
(代表问题作者发布)。
我最终修复了它,发生的是Gemfile.lock中的版本为“ sqlite3(1.4.0)”,但我需要的版本为“ sqlite3(1.3.13)”。我更改了版本,然后再次运行“ rake db:migrate”和“ rake db:seed”,现在可以正常工作了。
答案 1 :(得分:0)
您的应用程序可能正在Heroku上运行生产环境,但是您的Gemfile在开发和测试组中仅包含sqlite3。将sqlite3移出组,以便在所有环境中都可用并重新部署。
答案 2 :(得分:0)
使用Rails 5的sqlite3版本> 1.4.0出了点问题。在v1.3.11或v1.3.13的Gemfile中明确提到了sqlite3版本。 (宝石'sqlite3','〜> 1.3.11')