Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby AWS SDK错误。模块\u可继承\u attributes.rb中的值nil_Ruby_Aws Sdk - Fatal编程技术网

Ruby AWS SDK错误。模块\u可继承\u attributes.rb中的值nil

Ruby AWS SDK错误。模块\u可继承\u attributes.rb中的值nil,ruby,aws-sdk,Ruby,Aws Sdk,我有以下脚本: 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") 运行时,我遇到以下错误:

我有以下脚本:

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)
回溯(最近一次呼叫最后一次):
10:from script.rb:33:in`'
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\u 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\u inheritable\u attributes.rb:42:in“inheritable”:未定义nil:NilClass的“each”方法(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")