Bug #21723
open`binding.irb` raises a LoadError under `bundle exec` when Gemfile contains `path:` or `git:`
Description
In Ruby 4.0, binding.irb raises a LoadError when some unknown condition is met.
# main.rb
binding.irb
main.rb:1: warning: irb used to be loaded from the standard library, but is not part of the default gems since Ruby 4.0.0.
You can add irb to your Gemfile or gemspec to fix this error.
Failed to activate irb, please install it with 'gem install irb'
/Users/osyoyu/.rbenv/versions/master/lib/ruby/4.0.0+0/bundled_gems.rb:60:in 'Kernel.require': cannot load such file -- irb (LoadError)
Did you mean? erb
from /Users/osyoyu/.rbenv/versions/master/lib/ruby/4.0.0+0/bundled_gems.rb:60:in 'block (2 levels) in Kernel#replace_require'
from main.rb:1:in 'Binding#irb'
from main.rb:1:in '<main>'
/Users/osyoyu/.rbenv/versions/master/lib/ruby/4.0.0+0/bundled_gems.rb:60:in 'Kernel.require': cannot load such file -- irb (LoadError)
Did you mean? erb
from /Users/osyoyu/.rbenv/versions/master/lib/ruby/4.0.0+0/bundled_gems.rb:60:in 'block (2 levels) in Kernel#replace_require'
from main.rb:1:in 'Binding#irb'
from main.rb:1:in '<main>'
While irb has been changed to a bundle gem in #20309, it is agreed that binding.irb shall work under bundle exec without adding irb in Gemfile.
Thus, I've considered this behavior as an bug and created a ticket here.
One condition I have discovered is when the Gemfile contains a gem reference with a path: option.
I have created a repro repository in https://github.com/osyoyu/irbfail for that case.
Updated by osyoyu (Daisuke Aritomo) 19 days ago
Updated by hsbt (Hiroshi SHIBATA) 11 days ago
- Status changed from Open to Assigned
- Assignee set to hsbt (Hiroshi SHIBATA)
Updated by osyoyu (Daisuke Aritomo) 7 days ago
- Subject changed from `binding.irb` raises a LoadError under `bundle exec` to `binding.irb` raises a LoadError under `bundle exec` when Gemfile contains `path:` or `git:`
Updated by osyoyu (Daisuke Aritomo) 7 days ago
I have discovered that this issue reproduces when Gemfile contains a gem referred by path: or git:.
Such Gemfiles are pretty much common in real-world applications including Rails, which use in-house Gems and libraries, like this:
# binding.irb will fail under this Gemfile
gem "some-inhouse-gem", git: 'https://github.com/our-company/some-inhouse-gem.git'
Can the patch visited before Ruby 4.0 release?