ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:120047] [Ruby master Bug#20920] When loading a file, __FILE__ gets relative paths expanded only when they start with "./"
@ 2024-11-28 18:57 deivid via ruby-core
  2024-12-06 14:27 ` [ruby-core:120119] " Dan0042 (Daniel DeLorme) via ruby-core
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: deivid via ruby-core @ 2024-11-28 18:57 UTC (permalink / raw)
  To: ruby-core; +Cc: deivid

Issue #20920 has been reported by deivid (David Rodríguez).

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

* Author: deivid (David Rodríguez)
* Status: Open
* 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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:120119] [Ruby master Bug#20920] When loading a file, __FILE__ gets relative paths expanded only when they start with "./"
  2024-11-28 18:57 [ruby-core:120047] [Ruby master Bug#20920] When loading a file, __FILE__ gets relative paths expanded only when they start with "./" deivid via ruby-core
@ 2024-12-06 14:27 ` Dan0042 (Daniel DeLorme) via ruby-core
  2024-12-06 16:22 ` [ruby-core:120121] " vo.x (Vit Ondruch) via ruby-core
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Dan0042 (Daniel DeLorme) via ruby-core @ 2024-12-06 14:27 UTC (permalink / raw)
  To: ruby-core; +Cc: Dan0042 (Daniel DeLorme)

Issue #20920 has been updated by Dan0042 (Daniel DeLorme).


It's interesting that this highlights the only case where `load` searches in a different path than `require`

	if path is absolute
	  load/require absolute path --> __FILE__ is absolute
	elsif path starts with "." or ".."
	  load/require relative to pwd --> __FILE__ is expanded to absolute
	else
	  load/require relative to each $LOAD_PATH --> __FILE__ is expanded to absolute
	  if above not found, load (but not require) relative to pwd --> __FILE__ is NOT expanded to absolute
	end

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

* 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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:120121] [Ruby master Bug#20920] When loading a file, __FILE__ gets relative paths expanded only when they start with "./"
  2024-11-28 18:57 [ruby-core:120047] [Ruby master Bug#20920] When loading a file, __FILE__ gets relative paths expanded only when they start with "./" deivid via ruby-core
  2024-12-06 14:27 ` [ruby-core:120119] " Dan0042 (Daniel DeLorme) via ruby-core
@ 2024-12-06 16:22 ` vo.x (Vit Ondruch) via ruby-core
  2024-12-10 10:51 ` [ruby-core:120153] " deivid via ruby-core
  2025-01-09 11:33 ` [ruby-core:120568] " mame (Yusuke Endoh) via ruby-core
  3 siblings, 0 replies; 5+ messages in thread
From: vo.x (Vit Ondruch) via ruby-core @ 2024-12-06 16:22 UTC (permalink / raw)
  To: ruby-core; +Cc: vo.x (Vit Ondruch)

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


This is very related to #16978

And all this started with introduction of `require_relative` and it is a mess since then. IMHO, the path expansion is evil. It prevents usage of symlinks, it is troublesome with modifications of `$LOAD_PATH`, etc.

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

* 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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:120153] [Ruby master Bug#20920] When loading a file, __FILE__ gets relative paths expanded only when they start with "./"
  2024-11-28 18:57 [ruby-core:120047] [Ruby master Bug#20920] When loading a file, __FILE__ gets relative paths expanded only when they start with "./" deivid via ruby-core
  2024-12-06 14:27 ` [ruby-core:120119] " Dan0042 (Daniel DeLorme) via ruby-core
  2024-12-06 16:22 ` [ruby-core:120121] " vo.x (Vit Ondruch) via ruby-core
@ 2024-12-10 10:51 ` deivid via ruby-core
  2025-01-09 11:33 ` [ruby-core:120568] " mame (Yusuke Endoh) via ruby-core
  3 siblings, 0 replies; 5+ messages in thread
From: deivid via ruby-core @ 2024-12-10 10:51 UTC (permalink / raw)
  To: ruby-core; +Cc: deivid

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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:120568] [Ruby master Bug#20920] When loading a file, __FILE__ gets relative paths expanded only when they start with "./"
  2024-11-28 18:57 [ruby-core:120047] [Ruby master Bug#20920] When loading a file, __FILE__ gets relative paths expanded only when they start with "./" deivid via ruby-core
                   ` (2 preceding siblings ...)
  2024-12-10 10:51 ` [ruby-core:120153] " deivid via ruby-core
@ 2025-01-09 11:33 ` mame (Yusuke Endoh) via ruby-core
  3 siblings, 0 replies; 5+ messages in thread
From: mame (Yusuke Endoh) via ruby-core @ 2025-01-09 11:33 UTC (permalink / raw)
  To: ruby-core; +Cc: mame (Yusuke Endoh)

Issue #20920 has been updated by mame (Yusuke Endoh).


Discussed at the dev meeting. @matz suggested that we try modifying it so that only the `load "foo.rb"` case is a full path, and leave the other cases as is.

```
$ ruby foo.rb
foo.rb   # This should be kept

$ ruby ./foo.rb
./foo.rb # This should be kept

$ ruby -e 'load "foo.rb"'
foo.rb # This should be a full path

$ ruby -e 'load "./foo.rb"'
/full/path/to/foo.rb # This should be kept
```

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

* 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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-01-09 11:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-28 18:57 [ruby-core:120047] [Ruby master Bug#20920] When loading a file, __FILE__ gets relative paths expanded only when they start with "./" deivid via ruby-core
2024-12-06 14:27 ` [ruby-core:120119] " Dan0042 (Daniel DeLorme) via ruby-core
2024-12-06 16:22 ` [ruby-core:120121] " vo.x (Vit Ondruch) via ruby-core
2024-12-10 10:51 ` [ruby-core:120153] " deivid via ruby-core
2025-01-09 11:33 ` [ruby-core:120568] " mame (Yusuke Endoh) via ruby-core

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).