简体   繁体   中英

When attempting to deploy to Heroku ArgumentError: Missing required arguments: aws_access_key_id, aws_secret_access_key

There seems to be a lot of issue lately with people running into this issue and I have done my best to solve it through solutions on other queries related to this problem.

 # config/initializers/carrierwave.rb
if Rails.env.production? || Rails.env.development?
  CarrierWave.configure do |config|
    config.fog_credentials = {
      :provider               => 'AWS',                        # required
      :aws_access_key_id      => ENV['S3_ACCESS_KEY_ID'],                        # required
      :aws_secret_access_key  => ENV['S3_SECRET_ACCESS_KEY'],                        # required
      :region                 => 'us-east-2'                  # optional, defaults to 'us-east-1'
    }
    config.fog_directory  = 'cameronrailsbucket'                     # required
    config.fog_attributes = {'Cache-Control'=>'max-age=315576000'}  # optional, defaults to {}
    config.storage = :fog
  end
end

Heroku config is set like this:

S3_ACCESS_KEY_ID:         <ACCESS CODE>
S3_BUCKET:                cameronrailsbucket
S3_REGION:                us-east-2
S3_SECRET_ACCESS_KEY:     <SECRET CODE>

Error logs from attempted heroku push:

remote:        Running: rake assets:precompile
remote:        rake aborted!
remote:        ArgumentError: Missing required arguments: aws_access_key_id, aws_secret_access_key
remote:        /tmp/build_0940307f5f034abca7a6503938ab8031/vendor/bundle/ruby/2.2.0/gems/fog-core-1.43.0/lib/fog/core/service.rb:244:in `validate_options'
remote:        /tmp/build_0940307f5f034abca7a6503938ab8031/vendor/bundle/ruby/2.2.0/gems/fog-core-1.43.0/lib/fog/core/service.rb:268:in `handle_settings'
remote:        /tmp/build_0940307f5f034abca7a6503938ab8031/vendor/bundle/ruby/2.2.0/gems/fog-core-1.43.0/lib/fog/core/service.rb:98:in `new'
remote:        /tmp/build_0940307f5f034abca7a6503938ab8031/vendor/bundle/ruby/2.2.0/gems/fog-core-1.43.0/lib/fog/core/services_mixin.rb:16:in `new'
remote:        /tmp/build_0940307f5f034abca7a6503938ab8031/vendor/bundle/ruby/2.2.0/gems/fog-core-1.43.0/lib/fog/storage.rb:27:in `new'
remote:        /tmp/build_0940307f5f034abca7a6503938ab8031/vendor/bundle/ruby/2.2.0/gems/carrierwave-0.11.2/lib/carrierwave/uploader/configuration.rb:83:in `eager_load_fog'
remote:        /tmp/build_0940307f5f034abca7a6503938ab8031/vendor/bundle/ruby/2.2.0/gems/carrierwave-0.11.2/lib/carrierwave/uploader/configuration.rb:96:in `fog_credentials='
remote:        /tmp/build_0940307f5f034abca7a6503938ab8031/config/initializers/carrier_wave.rb:3:in `block in <top (required)>'
remote:        /tmp/build_0940307f5f034abca7a6503938ab8031/vendor/bundle/ruby/2.2.0/gems/carrierwave-0.11.2/lib/carrierwave/uploader/configuration.rb:118:in `configure'
remote:        /tmp/build_0940307f5f034abca7a6503938ab8031/vendor/bundle/ruby/2.2.0/gems/carrierwave-0.11.2/lib/carrierwave.rb:14:in `configure'
remote:        /tmp/build_0940307f5f034abca7a6503938ab8031/config/initializers/carrier_wave.rb:2:in `<top (required)>'
remote:        /tmp/build_0940307f5f034abca7a6503938ab8031/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:287:in `load'
remote:        /tmp/build_0940307f5f034abca7a6503938ab8031/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:287:in `block in load'
remote:        /tmp/build_0940307f5f034abca7a6503938ab8031/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
remote:        /tmp/build_0940307f5f034abca7a6503938ab8031/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:287:in `load'
remote:        /tmp/build_0940307f5f034abca7a6503938ab8031/vendor/bundle/ruby/2.2.0/gems/railties-5.0.1/lib/rails/engine.rb:648:in `block in load_config_initializer'
remote:        /tmp/build_0940307f5f034abca7a6503938ab8031/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.1/lib/active_support/notifications.rb:166:in `instrument'
remote:        /tmp/build_0940307f5f034abca7a6503938ab8031/vendor/bundle/ruby/2.2.0/gems/railties-5.0.1/lib/rails/engine.rb:647:in `load_config_initializer'
remote:        /tmp/build_0940307f5f034abca7a6503938ab8031/vendor/bundle/ruby/2.2.0/gems/railties-5.0.1/lib/rails/engine.rb:612:in `block (2 levels) in <class:Engine>'
remote:        /tmp/build_0940307f5f034abca7a6503938ab8031/vendor/bundle/ruby/2.2.0/gems/railties-5.0.1/lib/rails/engine.rb:611:in `each'
remote:        /tmp/build_0940307f5f034abca7a6503938ab8031/vendor/bundle/ruby/2.2.0/gems/railties-5.0.1/lib/rails/engine.rb:611:in `block in <class:Engine>'
remote:        /tmp/build_0940307f5f034abca7a6503938ab8031/vendor/bundle/ruby/2.2.0/gems/railties-5.0.1/lib/rails/initializable.rb:30:in `instance_exec'
remote:        /tmp/build_0940307f5f034abca7a6503938ab8031/vendor/bundle/ruby/2.2.0/gems/railties-5.0.1/lib/rails/initializable.rb:30:in `run'
remote:        /tmp/build_0940307f5f034abca7a6503938ab8031/vendor/bundle/ruby/2.2.0/gems/railties-5.0.1/lib/rails/initializable.rb:55:in `block in run_initializers'
remote:        /tmp/build_0940307f5f034abca7a6503938ab8031/vendor/bundle/ruby/2.2.0/gems/railties-5.0.1/lib/rails/initializable.rb:44:in `each'
remote:        /tmp/build_0940307f5f034abca7a6503938ab8031/vendor/bundle/ruby/2.2.0/gems/railties-5.0.1/lib/rails/initializable.rb:44:in `tsort_each_child'
remote:        /tmp/build_0940307f5f034abca7a6503938ab8031/vendor/bundle/ruby/2.2.0/gems/railties-5.0.1/lib/rails/initializable.rb:54:in `run_initializers'
remote:        /tmp/build_0940307f5f034abca7a6503938ab8031/vendor/bundle/ruby/2.2.0/gems/railties-5.0.1/lib/rails/application.rb:352:in `initialize!'
remote:        /tmp/build_0940307f5f034abca7a6503938ab8031/config/environment.rb:5:in `<top (required)>'
remote:        /tmp/build_0940307f5f034abca7a6503938ab8031/vendor/bundle/ruby/2.2.0/gems/railties-5.0.1/lib/rails/application.rb:328:in `require'
remote:        /tmp/build_0940307f5f034abca7a6503938ab8031/vendor/bundle/ruby/2.2.0/gems/railties-5.0.1/lib/rails/application.rb:328:in `require_environment!'
remote:        /tmp/build_0940307f5f034abca7a6503938ab8031/vendor/bundle/ruby/2.2.0/gems/railties-5.0.1/lib/rails/application.rb:448:in `block in run_tasks_blocks'
remote:        /tmp/build_0940307f5f034abca7a6503938ab8031/vendor/bundle/ruby/2.2.0/gems/sprockets-rails-3.2.0/lib/sprockets/rails/task.rb:62:in `block (2 levels) in define'
remote:        /tmp/build_0940307f5f034abca7a6503938ab8031/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
remote:        Tasks: TOP => environment
remote:        (See full trace by running task with --trace)
remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 

remote: ! Push rejected to fathomless-brushlands-57651. remote:

Any assistance would be greatly appreciated.

Make sure you have rake and rails environment to production over Heroku

heroku config
RACK_ENV:              production
RAILS_ENV:             production

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM