RubyGems 1.8.8 does not work with JRuby 1.6.3. #157

Closed
albertosaurus opened this Issue Aug 18, 2011 · 5 comments

Projects

None yet

4 participants

@albertosaurus

The problem is introduced with this commit: 0825eb3#diff-0

JRuby does not handle *args as expected:

Zlib::GzipReader.new(*args)
ArgumentError: wrong number of arguments (2 for 1)
        from (irb):5:in `evaluate'
        from org/jruby/RubyKernel.java:1093:in `eval'
        from org/jruby/RubyKernel.java:1419:in `loop'
        from org/jruby/RubyKernel.java:1205:in `catch'
        from org/jruby/RubyKernel.java:1205:in `catch'
@drbrain drbrain was assigned Aug 18, 2011
@luislavena
RubyGems member

@drbrain, seems the Encoding change is affecting JRuby?

@albertosaurus

Also filed a bug with JRuby: http://jira.codehaus.org/browse/JRUBY-6009

Not sure where the fix should be, as the ability to pass an arguments hash to GzipReader.new is an undocumented feature of 1.9.2. http://www.ruby-doc.org/stdlib/libdoc/zlib/rdoc/classes/Zlib/GzipReader.html#M010126 only shows the "io" as the only parameter to "new", but source says
if (argc > 1) {
opt = rb_check_convert_type(argv[argc-1], T_HASH, "Hash", "to_hash");
if (!NIL_P(opt)) argc--;
}

@drbrain
RubyGems member

The second argument of ZLib::GzipReader exists back to Ruby 1.9.1p0.

Since this is not new feature of Ruby 1.9.2 nor a Ruby 1.9.2 patchlevel a workaround for non-compliant Ruby implementations won't be added to RubyGems.

@drbrain drbrain closed this Aug 18, 2011
@baburdick

A hack, then, to workaround this issue until Ruby and RubyGems get along:

    # Strip superfluous args from Zlib::GzipReader instantiation:
    if defined? RUBY_ENGINE and 
       RUBY_ENGINE == 'jruby' and
       JRUBY_VERSION =~ /\A1.6.[0123]\Z/ and
       RUBY_VERSION =~ /\A1.9.[12]\Z/ then
      module Zlib
        class GzipReader
          alias :old_initialize :initialize
          def initialize *args
            old_initialize [*args][0]
          end
        end
      end
    end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment