#実現したいこと
heroku+carrierwave+S3にてデプロイを行おうとし、以下のコマンドを実行しました.
git push heroku master
#エラーメッセージ、問題
Preparing app for Rails asset pipeline remote: Running: rake assets:precompile remote: rake aborted! remote: NoMethodError: undefined method `[]' for nil:NilClass
! remote: ! Precompiling assets failed. remote: ! remote: ! Push rejected, failed to compile Ruby app. remote: remote: ! Push failed remote: ! remote: ! ## Warning - The same version of this code has already been built: a8360d84664bdeda2f248a42eac7233d7f58e783 remote: ! remote: ! We have detected that you have triggered a build from source code with version a8360d84664bdeda2f248a42eac7233d7f58e783 remote: ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch. remote: ! remote: ! If you are developing on a branch and deploying via git you must run: remote: ! remote: ! git push heroku <branchname>:main remote: ! remote: ! This article goes into details on the behavior: remote: ! https://devcenter.heroku.com/articles/duplicate-build-version remote: remote: Verifying deploy... remote: remote: ! Push rejected to game-reviewers. remote: To https://git.heroku.com/app-name.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'https://git.heroku.com/app-name.git'
該当のソースコード
CarrierWave.configure do |config| case Rails.env when 'development', 'test' config.storage = :file config.cache_storage = :file else config.fog_credentials = { provider: 'AWS', aws_access_key_id: Rails.application.credentials.aws[:access_key_id], aws_secret_access_key: Rails.application.credentials.aws[:secret_access_key], region: ENV['AWS_REGION'], } config.fog_provider = 'fog/aws' config.storage :fog config.cache_storage = :fog config.fog_directory = ENV['AWS_S3_BUCKET'] config.fog_public = false end end
#試したこと
こちらの記事を参考にして環境変数の編集やheroku configでAWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_S3_REGION, AWS_S3_BUCKETの環境変数を定義してherokuダッシュボードのConfig Varsでも確認しました。
ターミナル上でも環境変数が定義されていることを確認しましたが、同様なエラーが出てしまいます。
どなたかご協力お願いします。
#補足情報
rubyは3.0.1 railsは6.0.4 bundlerに2.2.21を使用しています
あなたの回答
tips
プレビュー