From: v.ondruch@...
Date: 2021-01-22T21:28:43+00:00
Subject: [ruby-core:102200] [Ruby master Feature#16978] Ruby should not use	realpath for __FILE__

Issue #16978 has been updated by vo.x (Vit Ondruch).


I have problem with double loading because of symlinks resolving into real path. If there was ensured that `require "foo"` load file just once, then double loading can't happen.

In Fedora, to avoid duplication, we have openssl gem extracted into independent package, which links back to the StdLib to keep the Ruby functionality. Unfortunately, since this commit [1], which introduces `require_relative`, we have issues with double loading. The simple reproducer is `ruby --disable-gems -e 'require "openssl"; require "openssl/digest"`.

You can admit that Fedora is doing something unexpected, but I think that the package split was done prior the `require_relative` was even introduced.


[1]: https://github.com/ruby/openssl/commit/74e03b588f58bcac007d7145c3bb6c4754daa1b0

----------------------------------------
Feature #16978: Ruby should not use realpath for __FILE__
https://bugs.ruby-lang.org/issues/16978#change-90047

* 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:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>