第一次尝试运行rake db:create
时,我不断收到错误Missing required arguments: aws_access_key_id, aws_secret_access_key (ArgumentError)
其他人发布了此问题并且响应是查看carrierwave.rb
文件,但我的存储库没有此文件。在fog.rb
里面我有:
CarrierWave.configure do |config|
config.fog_provider = 'fog/aws'
config.fog_credentials = {
provider: 'AWS', # required
region: ENV["AWS_REGION"], # optional, defaults to 'us-east-1'
aws_access_key_id: ENV["AWS_ACCESS_KEY_ID"],
aws_secret_access_key: ENV["AWS_SECRET_KEY"]
#,host: 's3.example.com', # optional, defaults to nil
#endpoint: 'https://s3.example.com:8080' # optional, defaults to nil
}
if Rails.env.development? || Rails.env.test?
config.fog_directory = 'policeboard-staging' # required
end
if Rails.env.production?
config.fog_directory = 'policeboard-production'
end
config.fog_public = true # optional, defaults to true
config.fog_attributes = { 'Cache-Control' => "max-age=#{365.day.to_i}" } # optional, defaults to {}
end
以下是错误日志:
/usr/local/opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/fog-core-1.42.0/lib/fog/core/service.rb:244:in `validate_options': Missing required arguments: aws_access_key_id, aws_secret_access_key (ArgumentError)
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/fog-core-1.42.0/lib/fog/core/service.rb:268:in `handle_settings'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/fog-core-1.42.0/lib/fog/core/service.rb:98:in `new'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/fog-core-1.42.0/lib/fog/core/services_mixin.rb:16:in `new'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/fog-core-1.42.0/lib/fog/storage.rb:27:in `new'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/bundler/gems/carrierwave-1dbc8be0bb8c/lib/carrierwave/uploader/configuration.rb:123:in `eager_load_fog'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/bundler/gems/carrierwave-1dbc8be0bb8c/lib/carrierwave/uploader/configuration.rb:136:in `fog_credentials='
from /Users/CharlieMerrill/code/policeboard/config/initializers/fog.rb:6:in `block in <top (required)>'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/bundler/gems/carrierwave-1dbc8be0bb8c/lib/carrierwave/uploader/configuration.rb:158:in `configure'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/bundler/gems/carrierwave-1dbc8be0bb8c/lib/carrierwave.rb:14:in `configure'
from /Users/CharlieMerrill/code/policeboard/config/initializers/fog.rb:2:in `<top (required)>'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `block in load'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/engine.rb:652:in `block in load_config_initializer'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/notifications.rb:166:in `instrument'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/engine.rb:651:in `load_config_initializer'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/engine.rb:616:in `block (2 levels) in <class:Engine>'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/engine.rb:615:in `each'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/engine.rb:615:in `block in <class:Engine>'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/initializable.rb:30:in `instance_exec'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/initializable.rb:30:in `run'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/initializable.rb:55:in `block in run_initializers'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/2.2.0/tsort.rb:226:in `block in tsort_each'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/2.2.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/2.2.0/tsort.rb:420:in `block (2 levels) in each_strongly_connected_component_from'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/2.2.0/tsort.rb:429:in `each_strongly_connected_component_from'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/2.2.0/tsort.rb:419:in `block in each_strongly_connected_component_from'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/initializable.rb:44:in `each'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/initializable.rb:44:in `tsort_each_child'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/2.2.0/tsort.rb:413:in `call'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/2.2.0/tsort.rb:413:in `each_strongly_connected_component_from'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/2.2.0/tsort.rb:347:in `block in each_strongly_connected_component'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/2.2.0/tsort.rb:345:in `each'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/2.2.0/tsort.rb:345:in `call'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/2.2.0/tsort.rb:345:in `each_strongly_connected_component'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/2.2.0/tsort.rb:224:in `tsort_each'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/2.2.0/tsort.rb:203:in `tsort_each'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/initializable.rb:54:in `run_initializers'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/application.rb:352:in `initialize!'
from /Users/CharlieMerrill/code/policeboard/config/environment.rb:5:in `<top (required)>'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `block in require'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/spring-1.7.2/lib/spring/application.rb:92:in `preload'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/spring-1.7.2/lib/spring/application.rb:143:in `serve'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/spring-1.7.2/lib/spring/application.rb:131:in `block in run'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/spring-1.7.2/lib/spring/application.rb:125:in `loop'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/spring-1.7.2/lib/spring/application.rb:125:in `run'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/spring-1.7.2/lib/spring/application/boot.rb:19:in `<top (required)>'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/opt/rbenv/versions/2.2.5/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from -e:1:in `<main>'
答案 0 :(得分:1)
查看您看到的错误消息:
Missing required arguments: aws_access_key_id, aws_secret_access_key
您似乎没有设置ENV
个变量:ENV["AWS_ACCESS_KEY_ID"]
和ENV["AWS_SECRET_KEY"]
。
您可以使用figaro
来提供帮助。查看该存储库并将其包含在您Gemfile
中。然后按照安装说明操作,它将帮助您在ENV
文件中设置application.yml
变量。确保不要将这些变量推送到公共存储库。
您还必须在用于托管的平台上设置这些ENV
变量。
另请查看此comparable SO Question以获取更多帮助。