Error configuring s3 with attachment_fu

Hi everyone,

I'm configuring attachment_fu to use s3, but I'm getting an error:

Image.new

NoMethodError: You have a nil object when you didn't expect it! The error occurred while evaluating nil.tmp_dh_callback=   from /usr/local/lib/ruby/gems/1.8/gems/rubyforge-1.0.0/lib/rubyforge/client.rb:24:in `use_ssl='   from /usr/local/lib/ruby/gems/1.8/gems/aws-s3-0.5.1/lib/aws/s3/connection.rb:101:in `create_connection'   from /usr/local/lib/ruby/gems/1.8/gems/aws-s3-0.5.1/lib/aws/s3/connection.rb:116:in `connect'   from /usr/local/lib/ruby/gems/1.8/gems/aws-s3-0.5.1/lib/aws/s3/connection.rb:23:in `initialize'   from /usr/local/lib/ruby/gems/1.8/gems/aws-s3-0.5.1/lib/aws/s3/connection.rb:6:in `new'   from /usr/local/lib/ruby/gems/1.8/gems/aws-s3-0.5.1/lib/aws/s3/connection.rb:6:in `connect'   from /usr/local/lib/ruby/gems/1.8/gems/aws-s3-0.5.1/lib/aws/s3/connection.rb:202:in `establish_connection!'   from /Users/sean/Projects/onecause/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/s3_backend.rb:143:in `included'   from /Users/sean/Projects/onecause/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:78:in `include'   from /Users/sean/Projects/onecause/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:78:in `has_attachment'   from /Users/sean/Projects/onecause/app/models/image.rb:27   from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:215:in `load_without_new_constant_marking'   from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:215:in `load_file'   from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:354:in `new_constants_in'   from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:214:in `load_file'   from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:95:in `require_or_load'   from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:260:in `load_missing_constant'   from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:467:in `const_missing_not_from_s3_library'   from /usr/local/lib/ruby/gems/1.8/gems/aws-s3-0.5.1/lib/aws/s3/extensions.rb:174:in `rake_original_const_missing'   from /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:2237:in `const_missing'   from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:479:in `const_missing'   from (irb):1

The gems are installed and included. The amazon_s3.yml file is configured correctly with the right bucket, access_key, and secret_access_key. The model is configured like this:

has_attachment :storage => :s3,                 :content_type => :image,                 :max_size => 500.kilobytes,                 :resize_to => '151x195>',                 :thumbnails => { :thumbnail => '100x100>'}

Any ideas? I can't find mention of tmp_dh_callback anywhere. If I use the same amazon_s3.yml in a new Rails tree, everything works fine, so it's not the network or my machine in particular.

Thanks!

Sean

Sean Hussey schreef:

Hi everyone,

I'm configuring attachment_fu to use s3, but I'm getting an error:

Image.new       

NoMethodError: You have a nil object when you didn't expect it! The error occurred while evaluating nil.tmp_dh_callback=   from /usr/local/lib/ruby/gems/1.8/gems/rubyforge-1.0.0/lib/rubyforge/client.rb:24:in `use_ssl='   from /usr/local/lib/ruby/gems/1.8/gems/aws-s3-0.5.1/lib/aws/s3/connection.rb:101:in `create_connection'   from /usr/local/lib/ruby/gems/1.8/gems/aws-s3-0.5.1/lib/aws/s3/connection.rb:116:in `connect'   from /usr/local/lib/ruby/gems/1.8/gems/aws-s3-0.5.1/lib/aws/s3/connection.rb:23:in `initialize'   from /usr/local/lib/ruby/gems/1.8/gems/aws-s3-0.5.1/lib/aws/s3/connection.rb:6:in `new'   from /usr/local/lib/ruby/gems/1.8/gems/aws-s3-0.5.1/lib/aws/s3/connection.rb:6:in `connect'   from /usr/local/lib/ruby/gems/1.8/gems/aws-s3-0.5.1/lib/aws/s3/connection.rb:202:in `establish_connection!'   from /Users/sean/Projects/onecause/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/s3_backend.rb:143:in `included'   from /Users/sean/Projects/onecause/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:78:in `include'   from /Users/sean/Projects/onecause/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:78:in `has_attachment'   from /Users/sean/Projects/onecause/app/models/image.rb:27   from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:215:in `load_without_new_constant_marking'   from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:215:in `load_file'   from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:354:in `new_constants_in'   from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:214:in `load_file'   from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:95:in `require_or_load'   from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:260:in `load_missing_constant'   from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:467:in `const_missing_not_from_s3_library'   from /usr/local/lib/ruby/gems/1.8/gems/aws-s3-0.5.1/lib/aws/s3/extensions.rb:174:in `rake_original_const_missing'   from /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:2237:in `const_missing'   from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:479:in `const_missing'   from (irb):1   from :0>>

The gems are installed and included. The amazon_s3.yml file is configured correctly with the right bucket, access_key, and secret_access_key. The model is configured like this:

has_attachment :storage => :s3,                 :content_type => :image,                 :max_size => 500.kilobytes,                 :resize_to => '151x195>',                 :thumbnails => { :thumbnail => '100x100>'}

Any ideas? I can't find mention of tmp_dh_callback anywhere. If I use the same amazon_s3.yml in a new Rails tree, everything works fine, so it's not the network or my machine in particular.

Thanks!

Sean

>

he problem is in the rubyforge 1.0.0 gem. It patches Net:HTTP but not very good, making the use_ssl=false call to cause an error. I posted a bug report to the rubyforge gem guys.

a quick fix is changing

@ssl_context.tmp_dh_callback = proc {}

into

@ssl_context.tmp_dh_callback = proc {} if flag

in the file client.rb (on my mac in /Library/Ruby/Gems/1.8/gems/rubyforge-1.0.0/lib/rubyforge/client.rb)

Wow, that was it. Thanks! Is there a link where I can view the progress of the bug?

I've got several hosts I'd need to patch with this, so I unpacked the gem into vendor/gems, made the change, and all seems well.

Thanks again!

Sean