[#115244] [Ruby master Feature#19987] add sample method to Range — "horv77@... (Andras Horvath) via ruby-core" <ruby-core@...>
Issue #19987 has been reported by horv77@protonmail.com (Andras Horvath).
6 messages
2023/11/05
[#115247] [Ruby master Feature#19988] AI for inner code behavior analysis at runtime — "horv77@... (Andras Horvath) via ruby-core" <ruby-core@...>
Issue #19988 has been reported by horv77@protonmail.com (Andras Horvath).
3 messages
2023/11/05
[#115404] Ruby 3.2.2 - rbconfig.rb's MAKEFILE_CONFIG — Jay Mav via ruby-core <ruby-core@...>
Hello Ruby Dev Team,
4 messages
2023/11/17
[ruby-core:115258] [Ruby master Bug#19985] Confusing error message when nonexistent `Pathname` for `require`
From:
"mame (Yusuke Endoh) via ruby-core" <ruby-core@...>
Date:
2023-11-06 09:15:49 UTC
List:
ruby-core #115258
Issue #19985 has been updated by mame (Yusuke Endoh).
A little explanation.
Actually, the builtin `Kernel#require` has accepted a Pathname object by calling #to_path.
```
$ cat test.rb
puts "Hello"
$ ruby -v --disable-gems -rpathname -e 'require Pathname("./test")'
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux]
Hello
```
However, if the file did not exist, it would unintentionally result in a TypeError.
```
$ ruby -v --disable-gems -rpathname -e 'require Pathname("./test2")'
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux]
-e:1:in `require': no implicit conversion of Pathname into String (TypeError)
from -e:1:in `<main>'
```
Therefore, nobu has fixed the bug by commit:4329554f171fdb483cafa672df5f2a08741940c5.
```
$ ./local/bin/ruby -v --disable-gems -rpathname -e 'require Pathname("./test")'
ruby 3.3.0dev (2023-11-06T08:58:47Z master 4329554f17) [x86_64-linux]
Hello
$ ./local/bin/ruby -v --disable-gems -rpathname -e 'require Pathname("./test2")'
ruby 3.3.0dev (2023-11-06T08:58:47Z master 4329554f17) [x86_64-linux]
-e:1:in `require': cannot load such file -- ./test2 (LoadError)
from -e:1:in `<main>'
```
----------------------------------------
Bug #19985: Confusing error message when nonexistent `Pathname` for `require`
https://bugs.ruby-lang.org/issues/19985#change-105174
* Author: vo.x (Vit Ondruch)
* Status: Closed
* Priority: Normal
* Backport: 3.0: REQUIRED, 3.1: REQUIRED, 3.2: REQUIRED
----------------------------------------
It seems that RubyGems / Bundler `require` method overrides of accept `Pathname` as and argument
~~~
$ ruby -rpathname -e '
pa = Pathname.new("test")
require pa
'
<internal:/usr/share/rubygems/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot load such file -- test (LoadError)
from <internal:/usr/share/rubygems/rubygems/core_ext/kernel_require.rb>:85:in `require'
from -e:3:in `<main>'
~~~
while plain Ruby require does not:
~~~
$ ruby --disable-gems -rpathname -e '
pa = Pathname.new("test")
require pa
'
-e:3:in `require': no implicit conversion of Pathname into String (TypeError)
from -e:3:in `<main>'
~~~
This inconsistency is surprising. It seems that RubyGems / Bundler developers think [1] that Ruby `require` should also accept `Pathname`.
~~~
$ ruby -v
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux]
~~~
[1]: https://github.com/rubygems/rubygems/pull/7128
--
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/postorius/lists/ruby-core.ml.ruby-lang.org/