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_path and similar that eventually attempt to expand a tilde to a HOME path.
RubyDir.getHomeDirectoryPath used by some of the above, which has several fallbacks to try to find a HOME but seems to not have quite enough?
- Load logic within
LoadService and LibrarySearcher. 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 in RubyDir but simple returns null if the HOME environment variable cannot be resolved, with no fallbacks.
When expanding a path starting with a tilde, like
~/foo, if theHOMEenvironment variable has been removed fromENVwe raise an error. MRI does not, and must be using some fallback logic to expandHOMEproperly when it has been cleared (or else capturing it at startup?).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?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.