`require_relative` does not work inside a jar on Windows #4188

Closed
presidentbeef opened this Issue Sep 29, 2016 · 3 comments

Projects

None yet

2 participants

@presidentbeef

This is a followup to #4000, the fix for which I believe was incomplete: d4cbfd2 I think the issue below is due to the path starting with classpath:c:/ instead of classpath:/

Environment

JRuby 9.1.5.0 complete jar.

Windows 8.1.

java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)

Expected Behavior

Load files in jar using require_relative.

Actual Behavior

> java -jar myapp.jar
LoadError: no such file to load -- classpath:C:/lib/test
           require at org/jruby/RubyKernel.java:956
  require_relative at uri:classloader:/jruby/kernel/kernel.rb:13
            <main> at classpath:/jar-bootstrap.rb:1

Steps to reproduce

Use https://github.com/presidentbeef/jruby-realpath-error

I happened to have a jruby-complete jar in ~/.jruby-jar/ so I use that below to build the jar on Linux. I'm not sure the Linux part is necessary, but that's where I started.

git clone https://github.com/presidentbeef/jruby-realpath-error.git
cd jruby-realpath-error
cp ~/.jruby-jar/jruby-complete-9.1.5.0.jar myapp.jar
jar ufe myapp.jar org.jruby.JarBootstrapMain jar-bootstrap.rb lib/test.rb

Copy jar to a Windows machine and run it:

java -jar myapp.jar
@headius headius added this to the JRuby 9.1.6.0 milestone Sep 30, 2016
@headius
Member
headius commented Sep 30, 2016

My fix probably should have just looked for "classpath:".

@headius headius closed this in ba74846 Sep 30, 2016
@headius
Member
headius commented Sep 30, 2016

I've pushed a fix but I'm not sure the best way to test it. Perhaps you can help us add something under spec/java_integration based on your reproduction?

Please confirm the fix works for you, too.

@presidentbeef

@headius how can I get a jruby-complete jar for jruby-head?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment