Skip to content

JRuby 9.2.0.0 canonicalizes paths in $" and __FILE__, making bundle exec fail when installed by RVM #5240

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

Open
eregon opened this issue Jul 6, 2018 · 3 comments · May be fixed by #6735
Open

Comments

@eregon
Copy link
Member

eregon commented Jul 6, 2018

Paths in $" and __FILE__ are canonicalized in JRuby 9.2.0.0.
They are not in MRI and in JRuby 9.1.16.0.
We have the same bug in TruffleRuby (oracle/truffleruby#1383).

This also causes bundle exec rake to fail when JRuby is installed with latest RVM, which installs RVM in a gem path with a symlink in it (GEM_PATH=/home/eregon/.rvm/gems/jruby-9.2.0.0:/home/eregon/.rvm/gems/jruby-9.2.0.0@global, the ...@global is a symlink), and Bundler then fails to detect its own lib path in $:, leading to removing it and further autoload/require of bundler files to fail.
See oracle/truffleruby#1383 (comment) for details as this is very condensed description.

I'll write a spec for this behavior.

Environment

Provide at least:

  • jruby 9.2.0.0 (2.5.0) 2018-05-24 81156a8 OpenJDK 64-Bit Server VM 25.151-b12 on 1.8.0_151-b12 +jit [linux-x86_64]
  • Linux
@eregon
Copy link
Member Author

eregon commented Jul 9, 2018

Specs in oracle/truffleruby@09cac1a

It's actually more complex than that since Ruby 2.4.4: on require "foo/bar", the foo/bar.rb part is not canonicalized, but the entry in $LOAD_PATH with that file in it is canonicalized.

So this essentially needs a fix in Bundler (rubygems/bundler#6502) and/or RVM (to avoid symlinks in GEM_PATH.).

@headius
Copy link
Member

headius commented Nov 12, 2018

Note that this is also causing "issues" when exceptions are raised from symlink-pathed files, as seen in #5436. Unclear how critical that particular case is, though, since it was only found due to error path-inspecting specs in Pry.

@headius
Copy link
Member

headius commented Apr 7, 2021

Remaining failures as of today:

  • Kernel#require_relative with a relative path ($LOADED_FEATURES) with symlinks does not canonicalize the path and stores a path with symlinks
  • Kernel#require ($LOADED_FEATURES) with symlinks does not canonicalize the path and stores a path with symlinks
  • Kernel#require ($LOADED_FEATURES) with symlinks in the required feature and $LOAD_PATH canonicalizes the entry in $LOAD_PATH but not the filename passed to #require
  • Kernel.require ($LOADED_FEATURES) with symlinks does not canonicalize the path and stores a path with symlinks
  • Kernel.require ($LOADED_FEATURES) with symlinks in the required feature and $LOAD_PATH canonicalizes the entry in $LOAD_PATH but not the filename passed to #require
  • Thread::Backtrace::Location#absolute_path canonicalization returns a canonical path without symlinks, even when __FILE__ does not
  • Thread::Backtrace::Location#absolute_path canonicalization returns a canonical path without symlinks, even when __FILE__ is removed
  • Thread::Backtrace::Location#path canonicalization returns a non-canonical path with symlinks, the same as __FILE__

Some or all of this could be fixed for 9.3 with final audits and fixes for load/require so I will leave this targeted for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants