2017-12-10 19 views
0

が初めてrake db:createを実行しようとしますが、私はMissing required arguments: aws_access_key_id, aws_secret_access_key (ArgumentError)欠落必要な引数: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>' 

答えて

1

あなたが見ているエラーメッセージをチェックしてください:

Missing required arguments: aws_access_key_id, aws_secret_access_key 

あなたがそれらを設定していないように見えますENV変数:ENV["AWS_ACCESS_KEY_ID"]およびENV["AWS_SECRET_KEY"]

figaroを利用すると便利です。そのリポジトリをチェックアウトし、Gemfileに含めてください。次に、インストール手順に従ってください。これは、application.ymlファイルにENV変数を設定するのに役立ちます。これらの変数をパブリックリポジトリにプッシュしないように注意してください。

これらの変数は、ホストするプラットフォームに合わせて設定する必要があります。

さらに詳しいヘルプについてはcomparable SO Questionをご覧ください。

+0

ありがとう、あなたの説明が理にかなっています。このリポジトリをクローンしてから、オリジナルのAWSキーをクリエイターから取得する必要がありますか? –

+0

このAWSアカウントに参加する必要がある場合は、はい。そうでなければ、これは練習用かそれとも何かのためのものであればいいえ。すべてはこのプロジェクトのコンテキストに依存します。 – jdgray

+0

ええ、私はこのサイトでいくつかの仕事をしているので、AWSアカウントに登録する必要があると思います。ご協力いただきありがとうございます! –

関連する問題