Skip to content
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
Closed

require_relative does not work inside a jar on Windows #4188

presidentbeef opened this issue Sep 29, 2016 · 5 comments

Comments

@presidentbeef
Copy link

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
Copy link
Member

headius commented Sep 30, 2016

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

@headius
Copy link
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
Copy link
Author

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

@stergiom
Copy link

@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
Copy link
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
Projects
None yet
Development

No branches or pull requests

3 participants