I just ran into a rather strange interaction between Ruby 1.8.7, rdoc, and ruby-debug that I think is worth documenting for the rest of the internet. This problem doesn’t come up if the ‘ruby-debug’ gem is not loaded when a rspec test requires ‘rdoc/rdoc’ but if all three are loaded into the same process you may run into the problem shown below.
The solution for me is to avoid running spec tests that require ‘rdoc/rdoc’ when I’m also running rspec in debug mode.
% rspec --debug spec
/Users/jeff/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/rdoc/parsers/parse_rb.rb:31: warning: already initialized constant EXPR_BEG
/Users/jeff/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/rdoc/parsers/parse_rb.rb:32: warning: already initialized constant EXPR_MID
/Users/jeff/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/rdoc/parsers/parse_rb.rb:33: warning: already initialized constant EXPR_END
/Users/jeff/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/rdoc/parsers/parse_rb.rb:34: warning: already initialized constant EXPR_ARG
/Users/jeff/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/rdoc/parsers/parse_rb.rb:35: warning: already initialized constant EXPR_FNAME
/Users/jeff/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/rdoc/parsers/parse_rb.rb:36: warning: already initialized constant EXPR_DOT
/Users/jeff/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/rdoc/parsers/parse_rb.rb:37: warning: already initialized constant EXPR_CLASS
/Users/jeff/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/rdoc/parsers/parse_rb.rb:262: warning: already initialized constant TokenDefinitions
/Users/jeff/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/rdoc/parsers/parse_rb.rb:267: warning: already initialized constant TkReading2Token
/Users/jeff/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/rdoc/parsers/parse_rb.rb:268: warning: already initialized constant TkSymbol2Token
/Users/jeff/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/rdoc/parsers/parse_rb.rb:273:in `def_token': uninitialized constant RubyToken::AlreadyDefinedToken (NameError)
from /Users/jeff/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/rdoc/parsers/parse_rb.rb:300
from /Users/jeff/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/rdoc/parsers/parse_rb.rb:299:in `each'
from /Users/jeff/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/rdoc/parsers/parse_rb.rb:299
from /Users/jeff/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /Users/jeff/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from /Users/jeff/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/rdoc/rdoc.rb:8
from /Users/jeff/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /Users/jeff/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from /Users/jeff/vms/puppet/src/puppet/spec/integration/util/rdoc/parser_spec.rb:9
from /Users/jeff/.rvm/gems/ruby-1.8.7-p334@puppet/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `load'
from /Users/jeff/.rvm/gems/ruby-1.8.7-p334@puppet/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `load_spec_files'
from /Users/jeff/.rvm/gems/ruby-1.8.7-p334@puppet/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `map'
from /Users/jeff/.rvm/gems/ruby-1.8.7-p334@puppet/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `load_spec_files'
from /Users/jeff/.rvm/gems/ruby-1.8.7-p334@puppet/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:18:in `run'
from /Users/jeff/.rvm/gems/ruby-1.8.7-p334@puppet/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:80:in `run_in_process'
from /Users/jeff/.rvm/gems/ruby-1.8.7-p334@puppet/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:69:in `run'
from /Users/jeff/.rvm/gems/ruby-1.8.7-p334@puppet/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:11:in `autorun'
from /Users/jeff/.rvm/gems/ruby-1.8.7-p334@puppet/bin/rspec:19







