CircleCIで、bitbuketへのpush時に、テストを自動で行いたいのですが、
bundle ecec rake db:create
コマンド実行時に
"NoMethodError: undefined method `[]' for nil:NilClass"
と、エラーが出てしまいます。
エラーを検索してみても、解決策が見つからず。どこに原因があるのかも見当がつきません、、、
どなたか見当がつく方がいらっしゃいましたら、ご教授お願いいたします。
発生しているエラー
#!/bin/bash -eo pipefail bundle exec rake db:create 2019-11-19 06:48:28 WARN Selenium [DEPRECATION] Selenium::WebDriver::Chrome#driver_path= is deprecated. Use Selenium::WebDriver::Chrome::Service#driver_path= instead. rake aborted! NoMethodError: undefined method `[]' for nil:NilClass /home/circleci/repo/config/initializers/devise.rb:20:in `block in <main>' /home/circleci/repo/vendor/bundle/ruby/2.6.0/gems/devise-4.7.1/lib/devise.rb:311:in `setup' /home/circleci/repo/config/initializers/devise.rb:5:in `<main>' /home/circleci/repo/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `load' /home/circleci/repo/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `load' /home/circleci/repo/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:285:in `block in load' /home/circleci/repo/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency' /home/circleci/repo/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:285:in `load' /home/circleci/repo/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/engine.rb:657:in `block in load_config_initializer' /home/circleci/repo/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/notifications.rb:170:in `instrument' /home/circleci/repo/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/engine.rb:656:in `load_config_initializer' /home/circleci/repo/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/engine.rb:614:in `block (2 levels) in <class:Engine>' /home/circleci/repo/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/engine.rb:613:in `each' /home/circleci/repo/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/engine.rb:613:in `block in <class:Engine>' /home/circleci/repo/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/initializable.rb:32:in `instance_exec' /home/circleci/repo/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/initializable.rb:32:in `run' /home/circleci/repo/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/initializable.rb:61:in `block in run_initializers' /home/circleci/repo/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/initializable.rb:50:in `each' /home/circleci/repo/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/initializable.rb:50:in `tsort_each_child' /home/circleci/repo/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/initializable.rb:60:in `run_initializers' /home/circleci/repo/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/application.rb:361:in `initialize!' /home/circleci/repo/config/environment.rb:7:in `<main>' /home/circleci/repo/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require' /home/circleci/repo/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi' /home/circleci/repo/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register' /home/circleci/repo/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi' /home/circleci/repo/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require' /home/circleci/repo/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require' /home/circleci/repo/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency' /home/circleci/repo/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require' /home/circleci/repo/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/application.rb:337:in `require_environment!' /home/circleci/repo/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/application.rb:520:in `block in run_tasks_blocks' /home/circleci/repo/vendor/bundle/ruby/2.6.0/gems/rake-13.0.0/exe/rake:27:in `<top (required)>' /usr/local/bin/bundle:23:in `load' /usr/local/bin/bundle:23:in `<main>' Tasks: TOP => db:create => db:load_config => environment (See full trace by running task with --trace) Exited with code 1
コード
circleci/config.yml
version: 2 jobs: rubocop: docker: - image: circleci/ruby:2.6.2-node-browsers-legacy environment: RAILS_ENV: test POSTGRES_HOST: 127.0.0.1 - image: circleci/postgres:11.5 environment: POSTGRES_USER: postgres POSTGRES_DB: myapp_test working_directory: ~/repo steps: - checkout - restore_cache: keys: - v2-dependencies-{{ checksum "Gemfile.lock" }} # fallback to using the latest cache if no exact match is found - v2-dependencies- - run: bundle install --jobs=4 --retry=3 --path vendor/bundle - save_cache: paths: - ./vendor/bundle key: v2-dependencies-{{ checksum "Gemfile.lock" }} # Rubocop - run: name: Rubocop command: bundle exec rubocop --auto-correct rspec: docker: - image: circleci/ruby:2.6.2-node-browsers-legacy environment: RAILS_ENV: test POSTGRES_HOST: 127.0.0.1 - image: circleci/postgres:11.5-alpine environment: POSTGRES_USER: postgres POSTGRES_DB: myapp_test working_directory: ~/repo steps: - checkout - restore_cache: keys: - v2-dependencies-{{ checksum "Gemfile.lock" }} - v2-dependencies- - run: name: install bundle command: | bundle install --jobs=4 --retry=3 --path vendor/bundle - save_cache: paths: - ./vendor/bundle key: v2-dependencies-{{ checksum "Gemfile.lock" }} - run: name: データベースの起動を待機 command: dockerize -wait tcp://127.0.0.1:5432 -timeout 1m #- run: mv config/database.yml.ci config/database.yml - run: bundle exec rake db:create - run: name: データベースのセットアップ command: bundle exec rake db:schema:load - run: name: gem install bundler command: gem install bundler # Align chrome-driver's version installed by chromedriver-helper - run: name: rspecを実行 command: bundle exec rspec - store_artifacts: path: tmp/screenshots/ destination: capybara workflows: version: 2 rubocop_rspec: jobs: - rubocop - rspec: requires: - rubocop
database.yml
default: &default adapter: postgresql encoding: unicode host: db username: postgres password: pool: 5 development: <<: *default database: myapp_development test: <<: *default database: myapp_test
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。