[Cloud9]Railsトラブルシューティング

はじめに

この文書の背景などをこちらに記してあります。参考にされてください。

2020/01/10 現在の情報

rails s した時に、「Gem::LoadError (Specified 'sqlite3' for database adapter, but the gem is not loaded. Add `gem 'sqlite3'` to your Gemfile」と出る場合


ms2sato:~/environment/qtest $ bin/rails s
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
=> Booting Puma
=> Rails 5.0.7.2 application starting in development on http://localhost:8080
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.12.2 (ruby 2.6.3-p62), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://localhost:8080
Use Ctrl-C to stop
Started GET "/" for 14.3.164.208 at 2020-01-09 13:10:14 +0000
Cannot render console from 14.3.164.208! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
  
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).):

sqlite のバージョンが合っていない様子なので、1.3系を指定すると良いでしょう。

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3', '~> 1.3.6' # バージョンを指定する

2019/09/03 現在の情報

bin/rake db:migrate で「Your version of SQLite (3.7.17) is too old. Active Record supports SQLite >= 3.8.」とエラーが出る場合


ms2sato:~/environment/rawrails (master) $ bin/rake db:migrate
RAILS_ENV=development environment is not defined in config/webpacker.yml, falling back to production environment
Running via Spring preloader in process 21284
rake aborted!
Your version of SQLite (3.7.17) is too old. Active Record supports SQLite >= 3.8.
/home/ec2-user/environment/rawrails/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.0/lib/active_record/connection_adapters/sqlite3_adapter.rb:336:in `check_version'
/home/ec2-user/environment/rawrails/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:880:in `block in new_connection'
/home/ec2-user/environment/rawrails/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:879:in `tap'
/home/ec2-user/environment/rawrails/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:879:in `new_connection'
/home/ec2-user/environment/rawrails/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:923:in `checkout_new_connection'
/home/ec2-user/environment/rawrails/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:902:in `try_to_checkout_new_connection'
/home/ec2-user/environment/rawrails/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:863:in `acquire_connection'
/home/ec2-user/environment/rawrails/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:587:in `checkout'
/home/ec2-user/environment/rawrails/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:431:in `connection'