2013-07-18 63 views
3

处理过期的项目,我需要调试但无法管理安装调试器。调试器 - 无法构建gem本机扩展ruby 1.8.7

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/[email protected]/gems/debugger-1.6.1 for inspection. 
Results logged to /Users/lfender/.rvm/gems/[email protected]/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. 

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

+0

'检查mkmf.log文件的更多细节 。您可能需要配置选项.' 您能发布此日志吗? –

回答

9

看起来好像debugger适用于Ruby 1.9.2 & 1.9.3,而ruby-debug可能更适合Ruby 1.8。

你可以尝试使用ruby-debug有:

gem install ruby-debug 

自述:

有运行红宝石调试的方法有两种。

中,RDebug可执行:

$ rdebug <your-script>

当您启动脚本这样,调试器将停止在代码在脚本文件的第一行。所以你可以设置你的断点。

红宝石调试API

第二种方法是使用红宝石调试API来打断你的代码执行在运行时。

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

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

当执行Kernel#debugger方法,调试器被激活,你将能够检查并通过您的代码步。

+0

工作得很好 - 谢谢! – lfender6445

-1

或者,你可以移动“调试”到开发区块在你的Gemfile:

group :development, :test do 
    gem 'debugger' 
end 
相关问题