jenkinsci/jenkins.rb

ruby-runtime 0.11 completely breaks RVM

Closed this issue · 6 comments

Indicating a ruby to build with via the RVM plugin results in:

Started by user anonymous
Building in workspace /u/jenkins/jobs/test/workspace
FATAL: (NameError) no method 'write' for arguments (org.jruby.RubyString) on Java::JavaIo::PrintStream
  available overloads:
    (int)
    (byte[])
org.jruby.exceptions.RaiseException: (NameError) no method 'write' for arguments (org.jruby.RubyString) on Java::JavaIo::PrintStream
  available overloads:
    (int)
    (byte[])
    at RUBY.<<(/u/jenkins/plugins/rvm/WEB-INF/classes/vendor/gems/gems/jenkins-plugin-runtime-0.1.17/lib/jenkins/model/listener.rb:32)
    at RUBY.setup(/u/jenkins/plugins/rvm/WEB-INF/classes/models/rvm_wrapper.rb:28)
    at RUBY.setUp(/u/jenkins/plugins/rvm/WEB-INF/classes/vendor/gems/gems/jenkins-plugin-runtime-0.1.17/lib/jenkins/plugin/proxies/build_wrapper.rb:18)

Downgrading to 0.10 fixes the issue.

yyuu commented

Please let me know the version of Jenkins.

yyuu commented

I confirmed this on Jenkins 1.517 + ruby-runtime 0.11 + rvm plugin 0.4. The cause of this problem is old gem dependency (jenkins-plugin-runtime 0.1.17) of rvm plugin 0.4.

Because the latest master of rvm plugin is using jenkins-plugin-runtime 0.2.3 (latest) at jenkinsci/rvm-plugin@e54486e, install rvm plugin from master should solve this problem. Though, there is another incompatibility issue (class hierarchy changes) between jenkins-plugin-runtime 0.1.17 and 0.2.3. Just upgrading rvm plugin may lose job configurations :(

It was Jenkins 1.504. I thought that upgrading the RVM plugin might solve the issue, but 0.4 is the latest released version, leaving me stuck.

yyuu commented

Yep, rvm plugin 0.4 is the latest release version. The latest development version can only be accessed via github repo.

yyuu commented

Tested with small script.

#!/usr/bin/env ruby
require "java"
puts(RUBY_DESCRIPTION)
java.lang.System.out.write("hello, world\n")

JRuby 1.6 translates call of write(String) on java.io.PrintStream as call of java.io.PrintStream#print(String).

% ruby j.rb
jruby 1.6.8 (ruby-1.8.7-p357) (2012-09-18 1772b40) (OpenJDK 64-Bit Server VM 1.7.0_21) [linux-amd64-java]
hello, world

JRuby 1.7 doesn't treat so.

% ruby j.rb
jruby 1.7.4 (1.9.3p392) 2013-05-16 2390d3b on OpenJDK 64-Bit Server VM 1.7.0_21-b02 [linux-amd64]
NameError: no method 'write' for arguments (org.jruby.RubyString) on Java::JavaIo::PrintStream
  available overloads:
    (int)
    (byte[])
  (root) at j.rb:4
yyuu commented

Confirmed that setting java_alias on java.io.PrintStream will solve problem on ruby-runtime 0.11+.

require "java"
java_import java.io.PrintStream
class PrintStream
  java_alias(:write, :print, [java.lang.String])
end