New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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

Comments

Projects
None yet
3 participants
@presidentbeef

presidentbeef commented Sep 29, 2016

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

This comment has been minimized.

Show comment
Hide comment
@headius

headius Sep 30, 2016

Member

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

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

This comment has been minimized.

Show comment
Hide comment
@headius

headius Sep 30, 2016

Member

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.

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

This comment has been minimized.

Show comment
Hide comment
@presidentbeef

presidentbeef Sep 30, 2016

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

presidentbeef commented Sep 30, 2016

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

@stergiom

This comment has been minimized.

Show comment
Hide comment
@stergiom

stergiom Mar 27, 2017

@presidentbeef is this still an issue for you? @headius I'm having the same classpath:C:/ case in both 9.1.7.0 and 9.1.8.0 on windows..

require_relative "./config/application"
VMain.launch
C:\Users\usr\Desktop>java -jar app.jar
LoadError: no such file to load -- classpath:C:/config/application
  require at org/jruby/RubyKernel.java:961
  require at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_
ext/kernel_require.rb:55
   <main> at classpath:/jar-bootstrap.rb:1

-is there a workaround if so?

stergiom commented Mar 27, 2017

@presidentbeef is this still an issue for you? @headius I'm having the same classpath:C:/ case in both 9.1.7.0 and 9.1.8.0 on windows..

require_relative "./config/application"
VMain.launch
C:\Users\usr\Desktop>java -jar app.jar
LoadError: no such file to load -- classpath:C:/config/application
  require at org/jruby/RubyKernel.java:961
  require at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_
ext/kernel_require.rb:55
   <main> at classpath:/jar-bootstrap.rb:1

-is there a workaround if so?

@headius

This comment has been minimized.

Show comment
Hide comment
@headius

headius Mar 27, 2017

Member

@stergiom I think your issue may be the same root cause as #4145 which I have fixed on master for 9.1.9.0. Can you try a build from master and see how it goes?

Member

headius commented Mar 27, 2017

@stergiom I think your issue may be the same root cause as #4145 which I have fixed on master for 9.1.9.0. Can you try a build from master and see how it goes?

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