Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

Loading `debug` gem breaks `blankslate` gem

Aberta
#757 5 comentários 1 reação 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
35/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Estagnada
Stack de tecnologia
ruby
Domínio
devtools

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

bug

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:

https://github.com/ruby/debug/blob/19b4dde3308f532943e4234d1588d4fa26c52345/lib/debug/session.rb#L1686-L1689

Why does the debug gem redefine this method?

Linguagem predominante
Ruby
Estrelas
1.3k
Forks
146
Métricas de merge de PRs
Nenhum PR com merge em 30d

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de ruby/debug

Todas as issues de ruby/debug

Issues semelhantes

Mais issues de Ruby

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.