truffleruby icon indicating copy to clipboard operation
truffleruby copied to clipboard

[Bug] Double loading symlinked files

Open itarato opened this issue 1 year ago • 3 comments

Consider the same file loaded twice, with and without a symlinked path:

mkdir real_dir
ln -s real_dir symlink_dir
cat 'puts("Loaded")' > real_dir/script.rb
require_relative("./real_dir/script")
require_relative("./symlink_dir/script")

CRuby loads the script once (Output = Loaded\n). TruffleRuby loads it twice (Output = Loaded\nLoaded\n).

Is this a bug?

itarato avatar Jun 27 '23 21:06 itarato

Yes, we should be compatible there. IIRC the logic CRuby in CRuby for which part of the path to expand symlinks changed quite a bit over time, possibly we don't match what latest CRuby does there.

eregon avatar Jun 28 '23 10:06 eregon

Does this issue happen in practice? It seems a change from 3.2, so I guess it would behave the same as TruffleRuby on CRuby 3.1 and before. cc @nirvdrum

eregon avatar Jul 28 '23 16:07 eregon

that was my experience, seemed to be a change in 3.2: https://github.com/oracle/truffleruby/pull/3189/files#diff-1be38982015c7d42487f6cb0dfd50ccb664506473122a57ec378d1f34440fcd9R407

rwstauner avatar Aug 17 '23 00:08 rwstauner