Project

General

Profile

Actions

Bug #19985

closed

Confusing error message when nonexistent `Pathname` for `require`

Added by vo.x (Vit Ondruch) 6 months ago. Updated 6 months ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:115227]

Description

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]
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like1Like0Like0Like0Like0Like0Like1Like2Like0Like0Like0