[ruby-core:102197] [Ruby master Feature#16978] Ruby should not use realpath for __FILE__
From:
akr@...
Date:
2021-01-22 18:20:00 UTC
List:
ruby-core #102197
Issue #16978 has been updated by akr (Akira Tanaka). I think we should use realpath. The location of actual file is more robust. Also, ELF dynamic linker has a feature, $ORIGIN, to refer a shared library using a relative path. It also resolves symlinks. https://refspecs.linuxbase.org/elf/gabi4+/ch5.dynamic.html ---------------------------------------- Feature #16978: Ruby should not use realpath for __FILE__ https://bugs.ruby-lang.org/issues/16978#change-90044 * 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: <mailto:[email protected]?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>