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

CWD is uri:classloader: then require_relative might not work #3176

Closed
mkristian opened this Issue Jul 24, 2015 · 3 comments

Comments

Projects
None yet
2 participants
@mkristian
Copy link
Member

commented Jul 24, 2015

file test.rb:

p __FILE__
require_relative 'other'

and file other.rb:

p 123

then following fails:

$ bin/jruby -C uri:classloader:/ test.rb
"test.rb"
LoadError: no such file to load -- /home/christian/projects/active/jruby/jruby17/uri:classloader:/other
           require at org/jruby/RubyKernel.java:1040
           require at /home/christian/projects/active/jruby/jruby17/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:54
  require_relative at file:/home/christian/projects/active/jruby/jruby17/lib/jruby.jar!/jruby/kernel19/kernel.rb:24
            (root) at test.rb:2

@mkristian mkristian self-assigned this Jul 24, 2015

@mkristian mkristian added this to the JRuby 1.7.22 milestone Jul 24, 2015

@mkristian

This comment has been minimized.

Copy link
Member Author

commented Jul 24, 2015

easier testcase:

$ bin/jruby -C uri:classloader:/ -e "p File.expand_path('other', '.')"
"/home/christian/projects/active/jruby/jruby17/uri:classloader:/other"

so expand_path fails with relative path when inside uri:classloader:/

mkristian added a commit that referenced this issue Jul 24, 2015

fixes expand_path on relative reference and inside uri:classloader: a…
…s CWD

using JRubyFile instead of regular File helps to keep the uri-like
paths intact.

fixes #3176

Sponsored by Lookout Inc.

@mkristian mkristian closed this Jul 24, 2015

@trejkaz

This comment has been minimized.

Copy link

commented Jul 29, 2015

Ah, this could be the issue I just found trying to require rspec. I only get it on Windows, though, and OSX seems to be no problem somehow (slash order?). Same issue or different?

Errno::ENOENT: No such file or directory - C:\hudson\workspace\trunk-functional-tests\os\windows\dependencies\jruby\jruby-testing-gems.jar!\gems\rspec-core-2.99.2\lib\rspec\core.rb
          realpath at org/jruby/RubyFile.java:805
  require_relative at uri:classloader:/jruby/kernel/kernel.rb:21
   block in (root) at c:/hudson/workspace/trunk-functional-tests/os/windows/dependencies/jruby/jruby-testing-gems.jar!/gems/rspec-core-2.99.2/lib/rspec/core.rb:3
              call at org/jruby/RubyProc.java:308
             <top> at c:/hudson/workspace/trunk-functional-tests/os/windows/dependencies/jruby/jruby-testing-gems.jar!/gems/rspec-core-2.99.2/lib/rspec/core.rb:14
           require at org/jruby/RubyKernel.java:940
            (root) at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1
             <top> at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:54
           require at org/jruby/RubyKernel.java:940
            (root) at c:/hudson/workspace/trunk-functional-tests/os/windows/dependencies/jruby/jruby-testing-gems.jar!/gems/rspec-2.99.0/lib/rspec.rb:1
             <top> at c:\hudson\workspace\trunk-functional-tests\os\windows/functional-tests/run-rspec.rb:8
@mkristian

This comment has been minimized.

Copy link
Member Author

commented Jul 29, 2015

C:\hudson\workspace\trunk-functional-tests\os\windows\dependencies\jruby\jruby-testing-gems.jar!\gems\rspec-core-2.99.2\lib\rspec\core.rb

this looks like the slashes after jar! are wrong. different issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.