前提・実現したいこと
新しくrailsでアプリを作成し、コントローラーを生成するためにrails g controller home top
のコマンドを打ったのですがエラーが出てしまい上手く行きません
以前まではエラーも出ず上手くいっていたのですが、最近docker環境でlaravelを構築したことがあり、それからエラーが出るようになってしまいました。
何卒解決方法をご教授お願いいたします。
発生している問題・エラーメッセージ
rb:188:in `rescue in spec': 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). (Gem::LoadError) from /Users/yusukewatanabe/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/activerecord-5.1.6.1/lib/active_record/connection_adapters/connection_specification.rb:185:in `spec' from /Users/yusukewatanabe/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/activerecord-5.1.6.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:880:in `establish_connection' from /Users/yusukewatanabe/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/activerecord-5.1.6.1/lib/active_record/connection_handling.rb:58:in `establish_connection' from /Users/yusukewatanabe/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/activerecord-5.1.6.1/lib/active_record/railtie.rb:124:in `block (2 levels) in <class:Railtie>' from /Users/yusukewatanabe/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/activesupport-5.1.6.1/lib/active_support/lazy_load_hooks.rb:69:in `instance_eval' from /Users/yusukewatanabe/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/activesupport-5.1.6.1/lib/active_support/lazy_load_hooks.rb:69:in `block in execute_hook' from /Users/yusukewatanabe/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/activesupport-5.1.6.1/lib/active_support/lazy_load_hooks.rb:60:in `with_execution_control' from /Users/yusukewatanabe/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/activesupport-5.1.6.1/lib/active_support/lazy_load_hooks.rb:65:in `execute_hook' from /Users/yusukewatanabe/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/activesupport-5.1.6.1/lib/active_support/lazy_load_hooks.rb:50:in `block in run_load_hooks' from /Users/yusukewatanabe/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/activesupport-5.1.6.1/lib/active_support/lazy_load_hooks.rb:49:in `each' from /Users/yusukewatanabe/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/activesupport-5.1.6.1/lib/active_support/lazy_load_hooks.rb:49:in `run_load_hooks' from /Users/yusukewatanabe/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/activerecord-5.1.6.1/lib/active_record/base.rb:326:in `<module:ActiveRecord>' from /Users/yusukewatanabe/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/activerecord-5.1.6.1/lib/active_record/base.rb:25:in `<top (required)>' from /Users/yusukewatanabe/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:292:in `require' from /Users/yusukewatanabe/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:292:in `block in require' from /Users/yusukewatanabe/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:258:in `load_dependency' from /Users/yusukewatanabe/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:292:in `require' from /Users/yusukewatanabe/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/application.rb:356:in `active_record_configured?' from /Users/yusukewatanabe/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/application.rb:273:in `disconnect_database' from /Users/yusukewatanabe/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/application.rb:107:in `preload' from /Users/yusukewatanabe/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/application.rb:153:in `serve' from /Users/yusukewatanabe/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/application.rb:141:in `block in run' from /Users/yusukewatanabe/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/application.rb:135:in `loop' from /Users/yusukewatanabe/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/application.rb:135:in `run' from /Users/yusukewatanabe/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/application/boot.rb:19:in `<top (required)>' from /Users/yusukewatanabe/.rbenv/versions/2.4.4/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:54:in `require' from /Users/yusukewatanabe/.rbenv/versions/2.4.4/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:54:in `require' from -e:1:in `<main>'
試したこと
エラーメッセージの言うようにgemfileにgem sqlite3を追加しようとしましたが、すでにありました。
そのあと、念のためbundle installを打って見ましたが、エラーは治りませんでした。
gemfile
1source 'https://rubygems.org' 2 3git_source(:github) do |repo_name| 4 repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") 5 "https://github.com/#{repo_name}.git" 6end 7 8 9# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 10gem 'rails', '~> 5.1.6', '>= 5.1.6.1' 11# Use sqlite3 as the database for Active Record 12gem 'sqlite3' 13# Use Puma as the app server 14gem 'puma', '~> 3.7' 15# Use SCSS for stylesheets 16gem 'sass-rails', '~> 5.0' 17# Use Uglifier as compressor for JavaScript assets 18gem 'uglifier', '>= 1.3.0' 19# See https://github.com/rails/execjs#readme for more supported runtimes 20# gem 'therubyracer', platforms: :ruby 21 22# Use CoffeeScript for .coffee assets and views 23gem 'coffee-rails', '~> 4.2' 24# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 25gem 'turbolinks', '~> 5' 26# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 27gem 'jbuilder', '~> 2.5' 28# Use Redis adapter to run Action Cable in production 29# gem 'redis', '~> 4.0' 30# Use ActiveModel has_secure_password 31# gem 'bcrypt', '~> 3.1.7' 32 33# Use Capistrano for deployment 34# gem 'capistrano-rails', group: :development 35 36group :development, :test do 37 # Call 'byebug' anywhere in the code to stop execution and get a debugger console 38 gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 39 # Adds support for Capybara system testing and selenium driver 40 gem 'capybara', '~> 2.13' 41 gem 'selenium-webdriver' 42end 43 44group :development do 45 # Access an IRB console on exception pages or by using <%= console %> anywhere in the code. 46 gem 'web-console', '>= 3.3.0' 47 gem 'listen', '>= 3.0.5', '< 3.2' 48 # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 49 gem 'spring' 50 gem 'spring-watcher-listen', '~> 2.0.0' 51end 52 53# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 54gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 55
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/02/17 06:12
退会済みユーザー
2019/02/17 06:21
2019/02/17 06:30
退会済みユーザー
2019/02/17 06:37
2019/02/17 06:45 編集
退会済みユーザー
2019/02/17 07:04
2019/02/17 07:17
退会済みユーザー
2019/02/17 07:18
2019/02/17 07:22 編集
退会済みユーザー
2019/02/17 07:26
2019/02/17 07:27
2019/02/17 07:29
退会済みユーザー
2019/02/17 07:29
2019/02/17 07:31
退会済みユーザー
2019/02/17 07:33
2019/02/17 07:37