# Uninitialized Constant Using New S3 Library

**URL:** <https://www.ruby-forum.com/t/uninitialized-constant-using-new-s3-library/78113>\
**Category:** Rails\
**Created:** [December 3, 2006, 12:09am UTC](https://www.ruby-forum.com/t/uninitialized-constant-using-new-s3-library/78113 "2006-12-03T00:09:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hunter\_h](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/bc79bd/32.png) [@hunter\_h](https://www.ruby-forum.com/u/hunter_h)\
**Post date:** [December 3, 2006, 12:09am UTC](https://www.ruby-forum.com/t/uninitialized-constant-using-new-s3-library/78113/1 "2006-12-03T00:09:11Z")

</div>

I am trying to use the new S3 library (thanks Marcel!) but I am  
getting an Uninitialized Constant message:

> > Service.buckets  
> > NameError: uninitialized constant Service  
> > from /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/  
> > lib/active\_support/dependencies.rb:100:in  
> > `const_missing_not_from_s3_library' from /opt/local/lib/ruby/gems/1.8/gems/aws-s3-0.1.1/lib/aws/ s3/extensions.rb:119:in`const\_missing’  
> > from /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/  
> > lib/active\_support/dependencies.rb:131:in `const\_missing’  
> > from (irb):2

I am calling the following in my environment.rb file:

require ‘aws/s3’  
AWS::S3::Base.establish\_connection!(:access\_key\_id =\>  
MY\_ID\_HERE, :secret\_access\_key =\> MY\_KEY\_HERE)

and then I fired up the console and tried the above and boom…

I also tried not putting the connection call in environment.rb and  
instead into a controller. Same deal.

I recently upgraded to the new gem:

aws-s3 (0.1.1, 0.1.0)  
Client library for Amazon’s Simple Storage Service’s REST API

Any ideas what I am doing wrong? I can run the command line client  
included in the gem without difficulty.

Thanks a ton,  
Hunter

---

<div class="post-metadata">

**Author:** ![hunter\_h](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/bc79bd/32.png) [@hunter\_h](https://www.ruby-forum.com/u/hunter_h)\
**Post date:** [January 14, 2010, 8:00am UTC](https://www.ruby-forum.com/t/uninitialized-constant-using-new-s3-library/78113/2 "2010-01-14T08:00:58Z")

</div>

Hunter H. wrote:

> I am trying to use the new S3 library (thanks Marcel!) but I am  
> getting an Uninitialized Constant message:
> 
> > > Service.buckets  
> > > NameError: uninitialized constant Service  
> > > from /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/  
> > > lib/active\_support/dependencies.rb:100:in  
> > > `const_missing_not_from_s3_library' from /opt/local/lib/ruby/gems/1.8/gems/aws-s3-0.1.1/lib/aws/ s3/extensions.rb:119:in`const\_missing’  
> > > from /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/  
> > > lib/active\_support/dependencies.rb:131:in `const\_missing’  
> > > from (irb):2
> 
> I am calling the following in my environment.rb file:
> 
> require ‘aws/s3’  
> AWS::S3::Base.establish\_connection!(:access\_key\_id =\>  
> MY\_ID\_HERE, :secret\_access\_key =\> MY\_KEY\_HERE)
> 
> and then I fired up the console and tried the above and boom…
> 
> I also tried not putting the connection call in environment.rb and  
> instead into a controller. Same deal.
> 
> I recently upgraded to the new gem:
> 
> aws-s3 (0.1.1, 0.1.0)  
> Client library for Amazon’s Simple Storage Service’s REST API
> 
> Any ideas what I am doing wrong? I can run the command line client  
> included in the gem without difficulty.
> 
> Thanks a ton,  
> Hunter

That is because Service is not accessible globally.

add the below line  
include AWS::S3

or access Service through

AWS::S3.Service

that should work.
