In my digging into this issue I also tried this ruby script to simulate what's not working in resolveScript
require 'java'
cfg = Java::OrgJruby::RubyInstanceConfig.new
puts "jruby.home #{ cfg.getJRubyHome }"
Java::OrgJrubyUtil::JRubyFile.create cfg.getJRubyHome, "bin/gem"
it ran as follows:
$ java -cp ~/.m2/repository/org/jruby/jruby-complete/1.6.7.2/jruby-complete-1.6.7.2.jar org.jruby.Main ./test.rb
jruby.home file:/Users/lachie/.m2/repository/org/jruby/jruby-complete/1.6.7.2/jruby-complete-1.6.7.2.jar!/META-INF/jruby.home
NativeException: java.lang.IllegalArgumentException: Neither current working directory (file:/Users/lachie/.m2/repository/org/jruby/jruby-complete/1.6.7.2/jruby-complete-1.6.7.2.jar!/META-INF/jruby.home) nor pathname (bin/gem) led to an absolute path
(root) at ./test.rb:6
Seems as though the problem is rooted in org.jruby.util.JRubyFile < jnr.posix.JavaSecuredFile < java.io.File
Because jruby.home is formatted as a file URL (starts with "file:") java.io.File#isAbsolute returns false.
I tried setting jruby.home to the same path without the "file:" but it caused problems later on in the JRuby startup process.
From what I can tell, we are searching the JAR, but failing to pick bin/gem. This failure leads to the search in $PATH, and the reported issue manifests.