Loading `debug` gem breaks `blankslate` gem
还没有人认领这个 Issue。
评估
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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?
- 主要语言
- Ruby
- 星标
- 1.3k
- 派生
- 146
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ruby/debug 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 68/100
-
Support exceptionOptions in setExceptionBreakpoints to catch arbitrary exception classes via DAP 未关闭
难度 4/5 3-5 天 新手友好度 55/100
-
难度 3/5 1-2 天 新手友好度 45/100
-
难度 4/5 3-5 天 新手友好度 52/100
-
难度 4/5 3-5 天 新手友好度 35/100
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
palladius/rails8-app-on-gcp#145 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 75/100
rubocop/rubocop-rspec#2236 ·
-
bug
难度 2/5 1-3 小时 新手友好度 70/100
riscv/riscv-unified-db#2624 · 1 个 reaction ·
-
难度 1/5 1 小时以内 新手友好度 88/100