Loading `debug` gem breaks `blankslate` gem
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Reproduce the interaction using the Ruby 2.7.2 and debug 1.6.2 environment described, then inspect lib/debug/session.rb around lines 1686-1689. Compare behavior with and without requiring debug, and verify the BlankSlate example remains compatible while determining the purpose of the redefinition.
Written by the indexing model from the issue text.
Description
Your environment
ruby -v: ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]rdbg -v: rdbg 1.6.2
Describe the bug
The debug gem undefines and redefines singleton_method_added.
The blankslate gem provides a "abstract base class with no predefined methods" except for some core Ruby builtins. "BlankSlate is useful as a base class when writing classes that depend upon method_missing (e.g. dynamic proxies)", so it only works if singleton_method_added is available. However, it hides singleton_method_added because it's redefined by the debug gem.
This problem does not occur when the debug gem is not required.
To Reproduce
require 'debug'
require 'blankslate'
BlankSlate.new.singleton_method_added
Buggy output -- the method isn't defined:
Traceback (most recent call last):
repro.rb:4:in `<main>': undefined method `singleton_method_added' for #<BlankSlate:0x000055a654b12fb0> (NoMethodError)
Expected behavior
The method is defined, but private:
Traceback (most recent call last):
repro.rb:3:in `<main>': private method `singleton_method_added' called for #<BlankSlate:0x000055d758dcd540> (NoMethodError)
Workaround
We can work around the bug by explicilty unhiding this method, or by requiring blankslate before debug:
BlankSlate.reveal(:singleton_method_added)
Additional context
The problem is caused by this code in the debug gem:
Why does the debug gem redefine this method?
- Dominant language
- Ruby
- Stars
- 1.3k
- Forks
- 146
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ruby/debug
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
Support exceptionOptions in setExceptionBreakpoints to catch arbitrary exception classes via DAP Open
Difficulty 4/5 3-5 days Newbie friendliness 55/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
notch8/utk_knapsack#148 ·
-
feature
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
betagouv/acces-cible#722 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
foobara/empty-ruby-project-generator#10 · 2 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100