调试器 - 无法构建gem native native ruby​​ 1.8.7

时间:2013-07-18 15:20:05

标签: ruby-on-rails ruby bundler

处理我需要调试但无法安装调试器的过时项目。

ruby -v  # => ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin12.3.0]
rails -v # => Rails 2.3.17

gem install debugger

Installing debugger (1.6.1)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /Users/lfender/.rvm/rubies/ruby-1.8.7-p352/bin/ruby extconf.rb
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
  --with-opt-dir
  --without-opt-dir
  --with-opt-include
  --without-opt-include=${opt-dir}/include
  --with-opt-lib
  --without-opt-lib=${opt-dir}/lib
  --with-make-prog
  --without-make-prog
  --srcdir=.
  --curdir
  --ruby=/Users/lfender/.rvm/rubies/ruby-1.8.7-p352/bin/ruby
extconf.rb:16:in `require': no such file to load -- debugger/ruby_core_source (LoadError)
  from extconf.rb:16


Gem files will remain installed in /Users/lfender/.rvm/gems/ruby-1.8.7-p352@nhg/gems/debugger-1.6.1 for inspection.
Results logged to /Users/lfender/.rvm/gems/ruby-1.8.7-p352@nhg/gems/debugger-1.6.1/ext/ruby_debug/gem_make.out

An error occurred while installing debugger (1.6.1), and Bundler cannot continue.
Make sure that `gem install debugger -v '1.6.1'` succeeds before bundling.

问题是阻止我调试一些失败的规范。任何帮助将不胜感激!

2 个答案:

答案 0 :(得分:9)

似乎debugger适用于Ruby 1.9.2& 1.9.3,ruby-debug可能更适合Ruby 1.8。

您可以尝试将ruby-debug用于:

gem install ruby-debug

来自自述文件:

运行ruby-debug有两种方法。

rdebug可执行文件:

$ rdebug <your-script>

以这种方式启动脚本时,调试器将停在脚本文件的第一行代码中。因此,您将能够设置断点。

ruby​​-debug API

第二种方法是使用ruby-debug API在运行时中断代码执行。

require 'ruby-debug' ; Debugger.start
...
def your_method
  ...
  debugger
  ...
end

require 'ruby-debug' ; 
Debugger.start do 
  ...
  debugger
end

执行Kernel#debugger方法后,调试器将被激活,您将能够检查并逐步执行代码。

答案 1 :(得分:-1)

或者,您可以将'debugger'移动到Gemfile中的开发块中:

group :development, :test do
  gem 'debugger'
end