Ruby AWS SDK 错误。 module_inheritable_attributes.rb 中的值为 nil
Ruby AWS SDK error. Value nil in module_inheritable_attributes.rb
我有以下脚本:
require 'httparty'
require 'aws-sdk-s3'
include HTTParty
Aws.config.update({
region: 'us-east-1',
credentials: Aws::Credentials.new('...', '...')
})
client = Aws::S3::Resource.new
movies = self.class.get("#{HOST}/movies")
当我 运行 它时,我遇到了以下错误:
Traceback (most recent call last):
10: from script.rb:33:in `<main>'
9: from script.rb:33:in `new'
8: from /Users/me/.rvm/gems/ruby-2.6.5/gems/aws-sdk-athena-1.22.0/lib/aws-sdk-athena/resource.rb:14:in `initialize'
7: from /Users/me/.rvm/gems/ruby-2.6.5/gems/aws-sdk-core-3.78.0/lib/seahorse/client/base.rb:99:in `new'
6: from /Users/me/.rvm/gems/ruby-2.6.5/gems/aws-sdk-athena-1.22.0/lib/aws-sdk-athena/client.rb:262:in `initialize'
5: from /Users/me/.rvm/gems/ruby-2.6.5/gems/aws-sdk-core-3.78.0/lib/seahorse/client/base.rb:19:in `initialize'
4: from /Users/me/.rvm/gems/ruby-2.6.5/gems/aws-sdk-core-3.78.0/lib/seahorse/client/base.rb:62:in `build_config'
3: from /Users/me/.rvm/gems/ruby-2.6.5/gems/aws-sdk-core-3.78.0/lib/seahorse/client/configuration.rb:149:in `build!'
2: from /Users/me/.rvm/gems/ruby-2.6.5/gems/aws-sdk-core-3.78.0/lib/seahorse/client/configuration.rb:158:in `empty_struct'
1: from /Users/me/.rvm/gems/ruby-2.6.5/gems/aws-sdk-core-3.78.0/lib/seahorse/client/configuration.rb:158:in `new'
/Users/me/.rvm/gems/ruby-2.6.5/gems/httparty-0.17.1/lib/httparty/module_inheritable_attributes.rb:42:in `inherited': undefined method `each' for nil:NilClass (NoMethodError)
查阅了 AWS 的文档和教程后,我仍然找不到问题所在。有什么问题吗?
我发现问题出在 include HTTParty
行。我在 之前 声明了 S3 客户端,它现在可以工作了:
require 'httparty'
require 'aws-sdk-s3'
Aws.config.update({
region: 'us-east-1',
credentials: Aws::Credentials.new('...', '...')
})
client = Aws::S3::Resource.new
include HTTParty
movies = self.class.get("#{HOST}/movies")
我有以下脚本:
require 'httparty'
require 'aws-sdk-s3'
include HTTParty
Aws.config.update({
region: 'us-east-1',
credentials: Aws::Credentials.new('...', '...')
})
client = Aws::S3::Resource.new
movies = self.class.get("#{HOST}/movies")
当我 运行 它时,我遇到了以下错误:
Traceback (most recent call last):
10: from script.rb:33:in `<main>'
9: from script.rb:33:in `new'
8: from /Users/me/.rvm/gems/ruby-2.6.5/gems/aws-sdk-athena-1.22.0/lib/aws-sdk-athena/resource.rb:14:in `initialize'
7: from /Users/me/.rvm/gems/ruby-2.6.5/gems/aws-sdk-core-3.78.0/lib/seahorse/client/base.rb:99:in `new'
6: from /Users/me/.rvm/gems/ruby-2.6.5/gems/aws-sdk-athena-1.22.0/lib/aws-sdk-athena/client.rb:262:in `initialize'
5: from /Users/me/.rvm/gems/ruby-2.6.5/gems/aws-sdk-core-3.78.0/lib/seahorse/client/base.rb:19:in `initialize'
4: from /Users/me/.rvm/gems/ruby-2.6.5/gems/aws-sdk-core-3.78.0/lib/seahorse/client/base.rb:62:in `build_config'
3: from /Users/me/.rvm/gems/ruby-2.6.5/gems/aws-sdk-core-3.78.0/lib/seahorse/client/configuration.rb:149:in `build!'
2: from /Users/me/.rvm/gems/ruby-2.6.5/gems/aws-sdk-core-3.78.0/lib/seahorse/client/configuration.rb:158:in `empty_struct'
1: from /Users/me/.rvm/gems/ruby-2.6.5/gems/aws-sdk-core-3.78.0/lib/seahorse/client/configuration.rb:158:in `new'
/Users/me/.rvm/gems/ruby-2.6.5/gems/httparty-0.17.1/lib/httparty/module_inheritable_attributes.rb:42:in `inherited': undefined method `each' for nil:NilClass (NoMethodError)
查阅了 AWS 的文档和教程后,我仍然找不到问题所在。有什么问题吗?
我发现问题出在 include HTTParty
行。我在 之前 声明了 S3 客户端,它现在可以工作了:
require 'httparty'
require 'aws-sdk-s3'
Aws.config.update({
region: 'us-east-1',
credentials: Aws::Credentials.new('...', '...')
})
client = Aws::S3::Resource.new
include HTTParty
movies = self.class.get("#{HOST}/movies")