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" fails in some cases (common Unix use case) #1724

Closed
bobjalex opened this issue Jun 4, 2014 · 2 comments
Closed

"require_relative" fails in some cases (common Unix use case) #1724

bobjalex opened this issue Jun 4, 2014 · 2 comments

Comments

@bobjalex
Copy link

bobjalex commented Jun 4, 2014

The following terminal session tells the story.
(Sorry about the long paths!)


A little Ruby program to do a require relative.

$ cat /Users/bobjalex/sbn/sideband/metal/x.rb

!/usr/bin/env ruby

p "loading"
require_relative "metal_lib"
p "done"


A symlink to the above program in /usr/local/bin (it's executable).

$ ls -l /usr/local/bin/x
lrwxr-xr-x 1 root admin 39 Jun 3 17:10 /usr/local/bin/x -> /Users/bobjalex/sbn/sideband/metal/x.rb


Our current directory. The target "metal_lib" is in it.

$ pwd
/Users/bobjalex/sbn/sideband/metal
$ ls metal_lib.rb
metal_lib.rb


/usr/local/bin is in the PATH (long path edited).

$ echo $PATH
...:/usr/local/bin


Run /usr/local/bin/x -- runs fine under Ruby 1.9.3.

$ rvm use 1.9
$ ruby -v
ruby 1.9.3p547 (2014-05-14 revision 45962) [x86_64-darwin13.2.0]
$ x
"loading"
"done"


Run /usr/local/bin/x using jruby. -- fails.

$ rvm jruby
$ ruby -v
jruby 1.7.12 (1.9.3p392) 2014-04-15 643e292 on Java HotSpot(TM) 64-Bit Server VM 1.8.0_05-b13 +indy [darwin-x86_64]
$ x
"loading"
LoadError: no such file to load -- /usr/local/bin/metal_lib
require at org/jruby/RubyKernel.java:1065
require at /Users/bobjalex/.rvm/rubies/jruby-1.7.12/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:55
require_relative at file:/Users/bobjalex/.rvm/rubies/jruby-1.7.12/lib/jruby.jar!/jruby/kernel19/kernel.rb:21
(root) at /usr/local/bin/x:3


Run the little program using jruby without the link -- works.

$ ./x.rb
"loading"
"done"

@MSNexploder
Copy link
Contributor

This works just as expected under 9.1.10.0

$ tree .
.
├── bar
│   └── x -> ../foo/x.rb
└── foo
    ├── metal_lib.rb
    └── x.rb

2 directories, 3 files
$ x
"loading"
"done"

@kares kares added this to the Invalid or Duplicate milestone Jun 12, 2017
@kares
Copy link
Member

kares commented Jun 12, 2017

thanks @MSNexploder - looks good, closing (report was against 1.7.x anyway - which is now EOL).

@kares kares closed this as completed Jun 12, 2017
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