From: deivid via ruby-core <ruby-core@...>
Date: 2024-12-10T10:51:40+00:00
Subject: [ruby-core:120153] [Ruby master Bug#20920] When loading a file, __FILE__ gets relative paths expanded only when they start with "./"

Issue #20920 has been updated by deivid (David Rodr�guez).


For what it's worth, this is not currently causing any issues in Bundler/RubyGems that I know of, so I changed the pending spec to track current Ruby's behavior and move on. From my side, this can be closed, but of course if Ruby maintainers think that it's worth and possible to bring more consistency here, I fully support that too.

----------------------------------------
Bug #20920: When loading a file, __FILE__ gets relative paths expanded only when they start with "./"
https://bugs.ruby-lang.org/issues/20920#change-110905

* Author: deivid (David Rodr�guez)
* Status: Open
* ruby -v: ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [arm64-darwin23]
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
```
$ cat foo.rb
puts __FILE__

$ ruby foo.rb              
foo.rb

$ ruby ./foo.rb            
./foo.rb

$ ruby -e 'load "foo.rb"'  
foo.rb

$ ruby -e 'load "./foo.rb"'
/full/path/to/foo.rb
```

More than an issue, this is mainly a question. In principle, it seems more consistent to me to either expand or not expand, but this is not causing real issues for me. I just want to figure out what to do with one pending spec in Bundler (https://github.com/rubygems/rubygems/blob/cd65092deb3168759820c613ecbc54cd9e06d46f/bundler/spec/commands/exec_spec.rb#L1023-L1028).



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/