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
Closed

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

mkristian opened this issue Jul 24, 2015 · 3 comments
Assignees
Milestone

Comments

@mkristian
Copy link
Member

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

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
…s CWD

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

fixes #3176

Sponsored by Lookout Inc.
@hakanai
Copy link

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

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

No branches or pull requests

2 participants