Rails 3.2.0 rspec调试器无法正常工作

时间:2012-02-06 04:46:53

标签: ruby-on-rails debugging rspec ruby-on-rails-3.2

我刚刚升级到ruby 1.9.3-p0和rails 3.2.0。我现在正尝试使用

在我的一个测试中调试错误
rspec spec -d

但是我收到了这个错误:

/home/map7/.rvm/gems/ruby-1.9.3-p0@rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:422:in `rescue in debug=':  (RuntimeError)
**************************************************
/home/map7/.rvm/gems/ruby-1.9.3-p0@rails3.2/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.so: undefined symbol: ruby_threadptr_data_type - /home/map7/.rvm/gems/ruby-1.9.3-p0@rails3.2/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.so

If you have it installed as a ruby gem, then you need to either require
'rubygems' or configure the RUBYOPT environment variable with the value
'rubygems'.

/home/map7/.rvm/gems/ruby-1.9.3-p0@rails3.2/gems/ruby-debug-base19-0.11.25/lib/ruby-debug-base.rb:1:in `require'
/home/map7/.rvm/gems/ruby-1.9.3-p0@rails3.2/gems/ruby-debug-base19-0.11.25/lib/ruby-debug-base.rb:1:in `<top (required)>'
/home/map7/.rvm/gems/ruby-1.9.3-p0@rails3.2/gems/ruby-debug19-0.11.6/cli/ruby-debug.rb:5:in `require'
/home/map7/.rvm/gems/ruby-1.9.3-p0@rails3.2/gems/ruby-debug19-0.11.6/cli/ruby-debug.rb:5:in `<top (required)>'
/home/map7/.rvm/gems/ruby-1.9.3-p0@rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:408:in `require'
/home/map7/.rvm/gems/ruby-1.9.3-p0@rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:408:in `debug='
/home/map7/.rvm/gems/ruby-1.9.3-p0@rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/configuration_options.rb:19:in `block in configure'
/home/map7/.rvm/gems/ruby-1.9.3-p0@rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/configuration_options.rb:18:in `each'
/home/map7/.rvm/gems/ruby-1.9.3-p0@rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/configuration_options.rb:18:in `configure'
/home/map7/.rvm/gems/ruby-1.9.3-p0@rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:21:in `run'
/home/map7/.rvm/gems/ruby-1.9.3-p0@rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:80:in `run_in_process'
/home/map7/.rvm/gems/ruby-1.9.3-p0@rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:69:in `run'
/home/map7/.rvm/gems/ruby-1.9.3-p0@rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:10:in `block in autorun'
**************************************************
    from /home/map7/.rvm/gems/ruby-1.9.3-p0@rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:407:in `debug='
    from /home/map7/.rvm/gems/ruby-1.9.3-p0@rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/configuration_options.rb:19:in `block in configure'
    from /home/map7/.rvm/gems/ruby-1.9.3-p0@rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/configuration_options.rb:18:in `each'
    from /home/map7/.rvm/gems/ruby-1.9.3-p0@rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/configuration_options.rb:18:in `configure'
    from /home/map7/.rvm/gems/ruby-1.9.3-p0@rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:21:in `run'
    from /home/map7/.rvm/gems/ruby-1.9.3-p0@rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:80:in `run_in_process'
    from /home/map7/.rvm/gems/ruby-1.9.3-p0@rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:69:in `run'
    from /home/map7/.rvm/gems/ruby-1.9.3-p0@rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:10:in `block in autorun'

5 个答案:

答案 0 :(得分:10)

安装适用于Ruby 1.9.3和1.9.2的新调试器gem:

https://github.com/cldwalker/debugger

答案 1 :(得分:4)

坚持使用Gemfile:

# one-liner to install these properly: bash < <(curl -L https://raw.github.com/gist/1333785)
gem 'linecache19', '0.5.13'
gem 'ruby-debug-base19', '0.11.26'

你需要运行那个单行程序才能让捆绑者拿起合适的宝石。

编辑:我忘记链接到我以前用于调试工作的帖子:

答案 2 :(得分:2)

我想我还不能对其他答案发表评论,但我发现很多这些说明都没有提到你还需要包括

gem 'ruby-debug19', :require => 'ruby-debug'

在你的Gemfile中,另外到siannopollo提供的指令。没有这个,我得到一个'无法加载这样的文件 - ruby​​-debug'错误(OSX,rvm,1.9.3-p125)。

FWIW,要点硬编码为1.9.3-p0,所以如果你使用1.9.3-p125,你可能需要编辑它(同样,执行你还没读过的要点通常是一个坏主意)。

答案 3 :(得分:2)

对我来说,只需要:

gem 'debugger'
Gemfile

中的

答案 4 :(得分:1)

必须升级以下

bundle update ruby-debug-base19