ruby-debug / ruby-debug-ide

An interface which glues ruby-debug to IDEs like Eclipse (RDT), NetBeans and RubyMine.
https://www.jetbrains.com/ruby/features/ruby_debugger.html
Other
371 stars 83 forks source link

warning: already initialized constant Thread #137

Closed CodeMonkeySteve closed 6 years ago

CodeMonkeySteve commented 6 years ago

Seeing lots of warnings about redefining Thread and OldThread, in thread-alias/alias_thread.rb and thread-alias/unalias_thread.rb. My workaround to silence the warnings (not sure if this is the best way):

alias_thread.rb:

unless defined?(OldThread)
  OldThread = Thread
  self.class.send(:remove_const, 'Thread')
  Thread = Debugger::DebugThread
end

unalias_thread.rb:

if defined?(OldThread)
  self.class.send(:remove_const, 'Thread')
  Thread = OldThread
  self.class.send(:remove_const, 'OldThread')
end
valich commented 6 years ago

@CodeMonkeySteve I can't conceive a better solution than using remove_const so I'd go for it.

I've pushed a fix with a couple of tests, and will update gem to beta3 soon. Please check it, if everything goes OK, I think it will make sense to port the fix to 0.6.1 branch.

CodeMonkeySteve commented 6 years ago

Your fix works great, thanks.