gpt4 book ai didi

ruby-on-rails - 缺少必需的参数 : aws_access_key_id, aws_secret_access_key

转载 作者:行者123 更新时间:2023-12-04 22:20:10 31 4
gpt4 key购买 nike

我目前正在尝试在终端中运行我的测试套件,但出现以下错误:
Missing required arguments: aws_access_key_id, aws_secret_access_key (ArgumentError)
我在我的项目中使用 Carrierwave,我很确定这就是导致问题的原因。这是我的 config/initializers/carrierwave.rb:

CarrierWave.configure do |config|
config.fog_credentials = {
:provider => 'AWS',
:aws_access_key_id => ENV['S3_ACCESS_KEY_ID'],
:aws_secret_access_key => ENV['S3_SECRET_ACCESS_KEY']
}
config.fog_directory = 'my_directory'

end

这是我的日志:
News-MacBook-Pro:music-app yedidyaweiner$ bundle exec rspec
/Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/gems/fog-core-1.27.2/lib/fog/core/service.rb:244:in `validate_options': Missing required arguments: aws_access_key_id, aws_secret_access_key (ArgumentError)
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/gems/fog-core-1.27.2/lib/fog/core/service.rb:268:in `handle_settings'
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/gems/fog-core-1.27.2/lib/fog/core/service.rb:98:in `new'
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/gems/fog-core-1.27.2/lib/fog/storage.rb:25:in `new'
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/gems/carrierwave-0.10.0/lib/carrierwave/uploader/configuration.rb:83:in `eager_load_fog'
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/gems/carrierwave-0.10.0/lib/carrierwave/uploader/configuration.rb:96:in `fog_credentials='
from /Users/yedidyaweiner/projects/music-app/config/initializers/carrierwave.rb:2:in `block in <top (required)>'
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/gems/carrierwave-0.10.0/lib/carrierwave/uploader/configuration.rb:118:in `configure'
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/gems/carrierwave-0.10.0/lib/carrierwave.rb:14:in `configure'
from /Users/yedidyaweiner/projects/music-app/config/initializers/carrierwave.rb:1:in `<top (required)>'
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:241:in `load'
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:241:in `block in load'
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in `load_dependency'
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:241:in `load'
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/gems/railties-4.1.1/lib/rails/engine.rb:648:in `block in load_config_initializer'
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/gems/activesupport-4.1.1/lib/active_support/notifications.rb:161:in `instrument'
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/gems/railties-4.1.1/lib/rails/engine.rb:647:in `load_config_initializer'
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/gems/railties-4.1.1/lib/rails/engine.rb:612:in `block (2 levels) in <class:Engine>'
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/gems/railties-4.1.1/lib/rails/engine.rb:611:in `each'
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/gems/railties-4.1.1/lib/rails/engine.rb:611:in `block in <class:Engine>'
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/gems/railties-4.1.1/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/gems/railties-4.1.1/lib/rails/initializable.rb:30:in `run'
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/gems/railties-4.1.1/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/yedidyaweiner/.rbenv/versions/2.1.2/lib/ruby/2.1.0/tsort.rb:226:in `block in tsort_each'
from /Users/yedidyaweiner/.rbenv/versions/2.1.2/lib/ruby/2.1.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
from /Users/yedidyaweiner/.rbenv/versions/2.1.2/lib/ruby/2.1.0/tsort.rb:418:in `block (2 levels) in each_strongly_connected_component_from'
from /Users/yedidyaweiner/.rbenv/versions/2.1.2/lib/ruby/2.1.0/tsort.rb:427:in `each_strongly_connected_component_from'
from /Users/yedidyaweiner/.rbenv/versions/2.1.2/lib/ruby/2.1.0/tsort.rb:417:in `block in each_strongly_connected_component_from'
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/gems/railties-4.1.1/lib/rails/initializable.rb:44:in `each'
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/gems/railties-4.1.1/lib/rails/initializable.rb:44:in `tsort_each_child'
from /Users/yedidyaweiner/.rbenv/versions/2.1.2/lib/ruby/2.1.0/tsort.rb:411:in `call'
from /Users/yedidyaweiner/.rbenv/versions/2.1.2/lib/ruby/2.1.0/tsort.rb:411:in `each_strongly_connected_component_from'
from /Users/yedidyaweiner/.rbenv/versions/2.1.2/lib/ruby/2.1.0/tsort.rb:347:in `block in each_strongly_connected_component'
from /Users/yedidyaweiner/.rbenv/versions/2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `each'
from /Users/yedidyaweiner/.rbenv/versions/2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `call'
from /Users/yedidyaweiner/.rbenv/versions/2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `each_strongly_connected_component'
from /Users/yedidyaweiner/.rbenv/versions/2.1.2/lib/ruby/2.1.0/tsort.rb:224:in `tsort_each'
from /Users/yedidyaweiner/.rbenv/versions/2.1.2/lib/ruby/2.1.0/tsort.rb:205:in `tsort_each'
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/gems/railties-4.1.1/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/gems/railties-4.1.1/lib/rails/application.rb:288:in `initialize!'
from /Users/yedidyaweiner/projects/music-app/config/environment.rb:5:in `<top (required)>'
from /Users/yedidyaweiner/projects/music-app/spec/rails_helper.rb:4:in `require'
from /Users/yedidyaweiner/projects/music-app/spec/rails_helper.rb:4:in `<top (required)>'
from /Users/yedidyaweiner/projects/music-app/spec/controllers/comments_controller_spec.rb:1:in `require'
from /Users/yedidyaweiner/projects/music-app/spec/controllers/comments_controller_spec.rb:1:in `<top (required)>'
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1058:in `load'
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1058:in `block in load_spec_files'
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1058:in `each'
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1058:in `load_spec_files'
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:97:in `setup'
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:85:in `run'
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:70:in `run'
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:38:in `invoke'
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/gems/rspec-core-3.0.4/exe/rspec:4:in `<top (required)>'
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/bin/rspec:23:in `load'
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/bin/rspec:23:in `<main>'
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/bin/ruby_executable_hooks:15:in `eval'
from /Users/yedidyaweiner/.rvm/gems/ruby-2.1.3/bin/ruby_executable_hooks:15:in `<main>'

我需要做什么来摆脱这个错误并运行我的测试?

最佳答案

您需要设置环境变量 S3_ACCESS_KEY_IDS3_SECRET_ACCESS_KEY,以便它们在 Rails 中可用。您可以在终端中执行此操作:

export S3_ACCESS_KEY_ID=<your access key id>
export S3_SECRET_ACCESS_KEY=<your secret access key>

将它们添加到您的 .bashrc 或 .bash_profile 中,以便在您下次启动新 shell 或使用类似 dotenv 的东西使它们特定于您的项目时仍然存在。

关于ruby-on-rails - 缺少必需的参数 : aws_access_key_id, aws_secret_access_key,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28995164/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com