Project

General

Profile

Actions

Bug #20920

open

When loading a file, __FILE__ gets relative paths expanded only when they start with "./"

Added by deivid (David Rodríguez) 20 days ago. Updated 9 days ago.

Status:
Open
Assignee:
-
Target version:
-
ruby -v:
ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [arm64-darwin23]
[ruby-core:120047]

Description

$ 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).

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0