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

File.realpath doesn't follow symlinks #538

Closed
ConradIrwin opened this issue Feb 18, 2013 · 4 comments
Closed

File.realpath doesn't follow symlinks #538

ConradIrwin opened this issue Feb 18, 2013 · 4 comments
Labels
Milestone

Comments

@ConradIrwin
Copy link
Contributor

I hoped this would just be a case of copying the logic from rubinius, https://github.com/rubinius/rubinius/blob/master/kernel/common/file19.rb#L98, however that code doesn't raise Errno::ENOENT in the case when the symlink is absent or broken rubinius/rubinius#2165. It might be better to copy the code from 1.8.7's Pathname#realpath which has the behaviour I was expecting.

@limhoff-r7
Copy link

As a work-around I did

file = java.io.File.new(path)
real_path = file.canonical_path

limhoff-r7 added a commit to rapid7/metasploit_data_models that referenced this issue Jun 17, 2014
[#50752269]

File.realpath does resolve symlinks in JRuby
(jruby/jruby#538).  To work-around the issue,
wrap compatibility code in MetasploitDataModels::File.realpath.
@LeeXGreen
Copy link

This might have been fixed at somepoint between 1.7.9 and 1.7.18:

leeg-mbp-13:~ lee$ ls -l /tmp/
total 16
-rw-r--r--  1 lee   wheel    0 Feb  8 12:36 file.rb
lrwxr-xr-x  1 lee   wheel    7 Feb  8 12:36 link.rb -> file.rb
lrwxr-xr-x  1 lee   wheel    7 Feb  8 12:36 link2.rb -> link.rb

leeg-mbp-13:~ lee$ rvm use 1.7.18
Using /Users/lee/.rvm/gems/jruby-1.7.18

leeg-mbp-13:~ lee$ irb
jruby-1.7.18 :001 > File.realpath('/tmp/link.rb')
 => "/private/tmp/file.rb"
jruby-1.7.18 :002 > File.realpath('/tmp/link2.rb')
 => "/private/tmp/file.rb"

@limhoff-r7
Copy link

JRuby 1.7.14 fixed the bug.

From: Lee Green
Reply-To: jruby/jruby
Date: Sunday, February 8, 2015 at 1:14 PM
To: jruby/jruby
Cc: Luke Imhoff
Subject: Re: [jruby] File.realpath doesn't follow symlinks (#538)

This might have been fixed at somepoint between 1.7.9 and 1.7.18:

leeg-mbp-13:~ lee$ ls -l /tmp/
total 16
-rw-r--r-- 1 lee wheel 0 Feb 8 12:36 file.rb
lrwxr-xr-x 1 lee wheel 7 Feb 8 12:36 link.rb -> file.rb
lrwxr-xr-x 1 lee wheel 7 Feb 8 12:36 link2.rb -> link.rb

leeg-mbp-13:~ lee$ rvm use 1.7.18
Using /Users/lee/.rvm/gems/jruby-1.7.18

leeg-mbp-13:~ lee$ irb
jruby-1.7.18 :001 > File.realpath('/tmp/link.rb')
=> "/private/tmp/file.rb"
jruby-1.7.18 :002 > File.realpath('/tmp/link2.rb')
=> "/private/tmp/file.rb"


Reply to this email directly or view it on GitHubhttps://github.com//issues/538#issuecomment-73426209.

@enebo enebo added this to the JRuby 1.7.14 milestone Feb 9, 2015
@enebo enebo added the core label Feb 9, 2015
@enebo
Copy link
Member

enebo commented Feb 9, 2015

Based on that snippet I am resolving against 1.7.14. Thanks for the sleuthing!

@enebo enebo closed this as completed Feb 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants