Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ruby 2.0 incompatibility #167

Open
smostovoy opened this issue May 22, 2013 · 9 comments
Open

ruby 2.0 incompatibility #167

smostovoy opened this issue May 22, 2013 · 9 comments

Comments

@smostovoy
Copy link

Hey,
Can't give more details for now but generally problem is next:
capistrano-ec2group + right_aws don't work after moving to ruby 2.0.
Looks like it has something to do with Ec2#describe_resources_with_list_and_options which passes to block something different in ruby1.9.3. In result @ec2_api.describe_instances always returns [].
Gem version - 3.0.5
I will continue research if you have no idea why is it happening

@unorthodoxgeek
Copy link

happens because in Ruby 2.0 Net::HTTP doesn't automatically unzip gzip responses.
I've solved this on my project by monkey patching the code like this:

module RightAws
  class RightAWSParser
    alias_method :old_parse, :parse
    def parse(xml_text, params={})
      if !xml_text.is_a?(String) && xml_text.to_hash["content-encoding"].include?("gzip")
        body = StringIO.new(xml_text.body)
        xml_text = Zlib::GzipReader.new(body).read
      end
      old_parse(xml_text, params)
    end
  end
end

should be handled by the gem, I guess... if this is a valid solution, I'd be happy to issue a Pull Request.

@stormsilver
Copy link

This monkey patch worked for me on gem version 3.1.0. Thank you!

@hammer65
Copy link

The problem I'm having is that in using S3 and simpleDB. S3 works fine, but simpleDB returns a blank result no matter what I query. It will raise the proper error when I access something I don't have permission for, and there is no error when I query something I do have access to, it just won't return results. I checked with a desktop simpleDB client and it works. Switching using RVM back to 1.8.7 works fine.

@rb2k
Copy link

rb2k commented Jan 20, 2014

I would appreciate this fix going in.
Ruby 2.0 has been out for a while...

@unorthodoxgeek
Copy link

this isn't a right_aws thing.
http://avi.io/blog/2013/12/17/do-not-upgrade-your-rails-project-to-ruby-2-before-you-read-this/

seems like whoever is maintaining Net::HTTP just went to sleep. the patch in this post is a must, regardless of which gem you're using. this is relevant for koala, aws, and many many more gems

@rb2k
Copy link

rb2k commented Jan 20, 2014

It seems like this would fix it:

ruby/ruby@f58d398

?

@unorthodoxgeek
Copy link

@rb2k - yup

@rb2k
Copy link

rb2k commented Jan 20, 2014

Weirdly enough, I still had to apply the manual fix to right_aws running on 2.1.0. Just looking through the parser class.

@grahamlyus
Copy link

@rb2k - It seems that the problem is actually in the right_http_connection gem, which overrides the request method and doesn't set decode_content on the response object.

Until that gem is updated, my workaround is to add the following to my Gemfile:

gem 'right_http_connection', git: 'git://github.com/rightscale/right_http_connection.git', ref: '3359524d81'

flexera-public/right_http_connection#20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants