-
-
Notifications
You must be signed in to change notification settings - Fork 928
Open
Description
When expanding a path starting with a tilde, like ~/foo, if the HOME environment variable has been removed from ENV we raise an error. MRI does not, and must be using some fallback logic to expand HOME properly when it has been cleared (or else capturing it at startup?).
[] ~/projects/jruby $ rvm ruby-2.5.3 do ruby -e 'ENV.delete("HOME"); p ENV["HOME"]; p File.expand_path "~/foo.rb"'
nil
"/Users/headius/foo.rb"
[] ~/projects/jruby $ ruby -e 'ENV.delete("HOME"); p ENV["HOME"]; p File.expand_path "~/foo.rb"'
nil
ArgumentError: couldn't find HOME environment -- expanding `~'
expand_path at org/jruby/RubyFile.java:844
<main> at -e:1
This manifests on current master and has probably been this way for a long time.
Note that we have logic for expanding the home path in various places that should be checked for this behavior:
RubyFile.expand_pathand similar that eventually attempt to expand a tilde to aHOMEpath.RubyDir.getHomeDirectoryPathused by some of the above, which has several fallbacks to try to find aHOMEbut seems to not have quite enough?- Load logic within
LoadServiceandLibrarySearcher. I'm currently working on a refactor of these, so the code is in flux. The logic I am now calling lives near the logic inRubyDirbut simple returns null if theHOMEenvironment variable cannot be resolved, with no fallbacks.
Metadata
Metadata
Assignees
Labels
No labels