尽管遵循此post,并找到了类似的答案here和here,我仍然在
ArgumentError:缺少必需的参数:aws_access_key_id,aws_secret_access_key`
当我尝试使用Carrierwave
和Fog
gems部署到Heroku时将图像上传到Amazon S3。
/config/initializers/carrierwave.rb:
if Rails.env.production?
CarrierWave.configure do |config|
config.fog_credentials = {
:provider => 'AWS',
:aws_access_key_id => ENV['S3_ACCESS_KEY'],
:aws_secret_access_key => ENV['S3_SECRET_KEY'],
:region => ENV['S3_REGION']
}
config.fog_directory = ENV['S3_BUCKET']
end
end
我设置了这样的Heroku配置:
S3_ACCESS_KEY: ABCDEFGHIJKPMNOPQRS
S3_BUCKET: mybucket12345
S3_REGION: us-west-2
S3_SECRET_KEY: 1234567890ABCDEFGHIJKLMNOPQRSTUVWZYZ1234
日志:
Running: rake assets:precompile
remote: rake aborted!
remote: ArgumentError: Missing required arguments: aws_access_key_id, aws_secret_access_key
remote: /tmp/build_d869b0ccafedcf0c55d666f657f499ac/vendor/bundle/ruby/2.2.0/gems/fog-core-1.43.0/lib/fog/core/service.rb:244:in `validate_options'
remote: /tmp/build_d869b0ccafedcf0c55d666f657f499ac/vendor/bundle/ruby/2.2.0/gems/fog-core-1.43.0/lib/fog/core/service.rb:268:in `handle_settings'
remote: /tmp/build_d869b0ccafedcf0c55d666f657f499ac/vendor/bundle/ruby/2.2.0/gems/fog-core-1.43.0/lib/fog/core/service.rb:98:in `new'
remote: /tmp/build_d869b0ccafedcf0c55d666f657f499ac/vendor/bundle/ruby/2.2.0/gems/fog-core-1.43.0/lib/fog/core/services_mixin.rb:16:in `new'
remote: /tmp/build_d869b0ccafedcf0c55d666f657f499ac/vendor/bundle/ruby/2.2.0/gems/fog-core-1.43.0/lib/fog/storage.rb:27:in `new'
remote: /tmp/build_d869b0ccafedcf0c55d666f657f499ac/vendor/bundle/ruby/2.2.0/gems/carrierwave-0.11.2/lib/carrierwave/uploader/configuration.rb:83:in `eager_load_fog'
remote: /tmp/build_d869b0ccafedcf0c55d666f657f499ac/vendor/bundle/ruby/2.2.0/gems/carrierwave-0.11.2/lib/carrierwave/uploader/configuration.rb:96:in `fog_credentials='
remote: /tmp/build_d869b0ccafedcf0c55d666f657f499ac/config/initializers/carrierwave.rb:2:in `block in <top (required)>'
remote: /tmp/build_d869b0ccafedcf0c55d666f657f499ac/vendor/bundle/ruby/2.2.0/gems/carrierwave-0.11.2/lib/carrierwave/uploader/configuration.rb:118:in `configure'
remote: /tmp/build_d869b0ccafedcf0c55d666f657f499ac/vendor/bundle/ruby/2.2.0/gems/carrierwave-0.11.2/lib/carrierwave.rb:14:in `configure'
remote: /tmp/build_d869b0ccafedcf0c55d666f657f499ac/config/initializers/carrierwave.rb:1:in `<top (required)>'
remote: /tmp/build_d869b0ccafedcf0c55d666f657f499ac/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `load'
remote: /tmp/build_d869b0ccafedcf0c55d666f657f499ac/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `block in load'
remote: /tmp/build_d869b0ccafedcf0c55d666f657f499ac/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
remote: /tmp/build_d869b0ccafedcf0c55d666f657f499ac/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `load'
remote: /tmp/build_d869b0ccafedcf0c55d666f657f499ac/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/engine.rb:648:in `block in load_config_initializer'
remote: /tmp/build_d869b0ccafedcf0c55d666f657f499ac/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/notifications.rb:166:in `instrument'
remote: /tmp/build_d869b0ccafedcf0c55d666f657f499ac/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/engine.rb:647:in `load_config_initializer'
remote: /tmp/build_d869b0ccafedcf0c55d666f657f499ac/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/engine.rb:612:in `block (2 levels) in <class:Engine>'
remote: /tmp/build_d869b0ccafedcf0c55d666f657f499ac/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/engine.rb:611:in `each'
remote: /tmp/build_d869b0ccafedcf0c55d666f657f499ac/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/engine.rb:611:in `block in <class:Engine>'
remote: /tmp/build_d869b0ccafedcf0c55d666f657f499ac/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/initializable.rb:30:in `instance_exec'
remote: /tmp/build_d869b0ccafedcf0c55d666f657f499ac/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/initializable.rb:30:in `run'
remote: /tmp/build_d869b0ccafedcf0c55d666f657f499ac/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/initializable.rb:55:in `block in run_initializers'
remote: /tmp/build_d869b0ccafedcf0c55d666f657f499ac/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/initializable.rb:44:in `each'
remote: /tmp/build_d869b0ccafedcf0c55d666f657f499ac/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/initializable.rb:44:in `tsort_each_child'
remote: /tmp/build_d869b0ccafedcf0c55d666f657f499ac/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/initializable.rb:54:in `run_initializers'
remote: /tmp/build_d869b0ccafedcf0c55d666f657f499ac/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/application.rb:352:in `initialize!'
remote: /tmp/build_d869b0ccafedcf0c55d666f657f499ac/config/environment.rb:5:in `<top (required)>'
remote: /tmp/build_d869b0ccafedcf0c55d666f657f499ac/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
remote: /tmp/build_d869b0ccafedcf0c55d666f657f499ac/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require'
remote: /tmp/build_d869b0ccafedcf0c55d666f657f499ac/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
remote: /tmp/build_d869b0ccafedcf0c55d666f657f499ac/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
remote: /tmp/build_d869b0ccafedcf0c55d666f657f499ac/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/application.rb:328:in `require_environment!'
remote: /tmp/build_d869b0ccafedcf0c55d666f657f499ac/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/application.rb:448:in `block in run_tasks_blocks'
remote: /tmp/build_d869b0ccafedcf0c55d666f657f499ac/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_d869b0ccafedcf0c55d666f657f499ac/vendor/bundle/ruby/2.2.0/gems/rake-11.3.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
答案 0 :(得分:0)
尝试:
添加到您的gemfile:gem "figaro"
figaro heroku:set -e production
rake figaro:heroku
再次推送到heroku