jirutka / asciidoctor-interdoc-reftext

Asciidoctor extension providing implicit (automatic) reference text (label) for inter-document cross references
MIT License
9 stars 4 forks source link

Working with Ruby 3.1+ #8

Open Chrispie opened 1 week ago

Chrispie commented 1 week ago

Hi I am trying to implement this in my gradle project but running into an issue. It seems like it is relating to the Ruby version 3.1 onwards.

I have setup a sample project here with just 2 asciidoc files and a gradle build.

In my build.gradle file if I set the JRuby version to

The error that I am getting is in the processor.rb class on line 67:

Caused by: org.jruby.exceptions.ArgumentError: (ArgumentError) wrong number of arguments (given 1, expected 0)
    at RUBY.initialize(uri:classloader:/gems/asciidoctor-interdoc-reftext-0.5.3/lib/asciidoctor/interdoc_reftext/processor.rb:66)
    at org.jruby.RubyClass.new(org/jruby/RubyClass.java:922)
    at RUBY.add_document_processor(uri:classloader:/gems/asciidoctor-2.0.23/lib/asciidoctor/extensions.rb:1387)
    at RUBY.tree_processor(uri:classloader:/gems/asciidoctor-2.0.23/lib/asciidoctor/extensions.rb:844)
    at RUBY.<main>(uri:classloader:/gems/asciidoctor-interdoc-reftext-0.5.3/lib/asciidoctor/interdoc_reftext.rb:10)
    at org.jruby.RubyBasicObject.instance_exec(org/jruby/RubyBasicObject.java:2620)
    at RUBY.activate(uri:classloader:/gems/asciidoctor-2.0.23/lib/asciidoctor/extensions.rb:744)
    at org.jruby.RubyArray.each(org/jruby/RubyArray.java:1981)
    at RUBY.activate(uri:classloader:/gems/asciidoctor-2.0.23/lib/asciidoctor/extensions.rb:739)
    at RUBY.initialize(uri:classloader:/gems/asciidoctor-2.0.23/lib/asciidoctor/document.rb:498)
    at org.jruby.RubyClass.new(org/jruby/RubyClass.java:935)
    at RUBY.load(uri:classloader:/gems/asciidoctor-2.0.23/lib/asciidoctor/load.rb:84)

My knowledge of Ruby is just too little to know why. I have seen though that on a stackoverflow site that in the later versions of Ruby the () is needed on a super call. Do you know if there are any other way to get around this to enforce a later version of ruby?

jirutka commented 1 week ago

Hi,

9.3.14.0 it works -> From my understanding 9.3.x will work with Ruby 2.6.x 9.4.7.0 it fails -> From my understanding 9.4.x will work with Ruby 3.1.x

That’s not correct; 9.3.x is compatible with Ruby 2.6.x, 9.4.x is compatible with Ruby 3.1.x.

asciidoctor-interdoc-reftext 0.5.2 is compatible with Ruby 2.1–2.7. Version 0.5.3 is compatible with 2.7 and 3.x (Ruby 2.6 is unsupported by upstream for many many years). It’s tested on CI even against the latest JRuby and all tests passed last month.

uri:classloader:/gems/asciidoctor-interdoc-reftext-0.5.4

This is suspicious… the latest released version is 0.5.3, there’s no 0.5.4 (yet).

I have seen though that on a stackoverflow site that in the later versions of Ruby the () is needed on a super call.

I’m quite sure it’s not; parens in function calls are optional in Ruby.

Chrispie commented 1 week ago

Apologies for the 0.54. I tried playing around with the source code (I corrected my log output in the original question to avoid confusion).

I upgraded from 0.5.2 to 0.5.3. I get the exact same behavior when using JRuby 9.4.7.0:

Caused by: org.jruby.exceptions.ArgumentError: (ArgumentError) wrong number of arguments (given 1, expected 0)
    at RUBY.initialize(uri:classloader:/gems/asciidoctor-interdoc-reftext-0.5.3/lib/asciidoctor/interdoc_reftext/processor.rb:66)
    at org.jruby.RubyClass.new(org/jruby/RubyClass.java:922)
    at RUBY.add_document_processor(uri:classloader:/gems/asciidoctor-2.0.23/lib/asciidoctor/extensions.rb:1387)
    at RUBY.tree_processor(uri:classloader:/gems/asciidoctor-2.0.23/lib/asciidoctor/extensions.rb:844)
    at RUBY.<main>(uri:classloader:/gems/asciidoctor-interdoc-reftext-0.5.3/lib/asciidoctor/interdoc_reftext.rb:10)
    at org.jruby.RubyBasicObject.instance_exec(org/jruby/RubyBasicObject.java:2620)
    at RUBY.activate(uri:classloader:/gems/asciidoctor-2.0.23/lib/asciidoctor/extensions.rb:744)
    at org.jruby.RubyArray.each(org/jruby/RubyArray.java:1981)
    at RUBY.activate(uri:classloader:/gems/asciidoctor-2.0.23/lib/asciidoctor/extensions.rb:739)
    at RUBY.initialize(uri:classloader:/gems/asciidoctor-2.0.23/lib/asciidoctor/document.rb:498)
    at org.jruby.RubyClass.new(org/jruby/RubyClass.java:935)
    at RUBY.load(uri:classloader:/gems/asciidoctor-2.0.23/lib/asciidoctor/load.rb:84)`

I tried downgrading JRuby as well. It happens in 9.4.0.0. Looks like something does not work with JRuby going from 9.3.14 to 9.4.0.0.