Reputation: 815
When trying to create a new bucket in an S3 account using the ruby aws-sdk version 2, I always get the following exception:
NoMethodError: undefined method `location_name' for nil:NilClass
index_members_by_location_name at /home/ubuntu/.rvm/gems/jruby-1.7.4/gems/aws-sdk-core-2.0.21/lib/seahorse/model/shapes.rb:283
...
I initialized the S3 client with the correct region and correct credentials. The following is part of my sample code:
...
s3 = Aws::S3::Client.new(region: region, credentials: credentials)
bucket = s3.create_bucket(bucket: 'mynewbucket')
puts bucket.inspect
# List the available buckets
puts "Available buckets:"
resp = s3.list_buckets
resp.buckets.each do |bucket|
puts bucket.inspect
end
One note is that the code that lists the buckets works fine. Anyone knows what am I doing wrong?
EDIT:
I even added this code in order to list the objects in an existing bucket, and it throws the exact same error as above:
resp = s3.list_objects(bucket: 'existingbucket')
resp.contents.each do |object|
puts "#{object.key} => #{object.etag}"
end
Upvotes: 3
Views: 810
Reputation: 6528
That error is caused by a bug in JRuby 1.7.4 and how it handles the enumerable #inject and #each.with_object. Upgrading JRuby will resolve this issue.
Upvotes: 2