From: v.ondruch@... Date: 2020-07-09T21:47:08+00:00 Subject: [ruby-core:99103] [Ruby master Feature#16978] Ruby should not use realpath for __FILE__ Issue #16978 has been updated by vo.x (Vit Ondruch). > this code would change behavior: Absolutely, different `$LOAD_PATH` must result in different behavior. > ~~~ > $: << 'a' > require 'test' > $: << 'b' > require 'test' > # Current: not loaded again > # Your proposed: loaded again > ~~~ This is actually where I am coming from. I am not 100 % sure what is the spec of `require`, but I would expect that `require 'test'` works just once and it does not matter what is the current `$LOAD_PATH` status. So my proposal is actually: ~~~ # Your proposed: not loaded again ~~~ ---------------------------------------- Feature #16978: Ruby should not use realpath for __FILE__ https://bugs.ruby-lang.org/issues/16978#change-86477 * Author: vo.x (Vit Ondruch) * Status: Open * Priority: Normal ---------------------------------------- This is the simplest test case: ~~~ $ mkdir a $ echo "puts __FILE__" > a/test.rb $ ln -s a b $ ruby -Ib -e "require 'test'" /builddir/a/test.rb ~~~ This behavior is problematic, because Ruby should not know nothing about the `a` directory. It was not instructed to use it. I should always refer to the file using the original path and do not dig into the underlying details, otherwise depending on file system setup, one might be forced to used `File.realpath` everywhere trying to use `__FILE__`. -- https://bugs.ruby-lang.org/ Unsubscribe: