简体   繁体   English

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

[英]Debugger - Failed to build gem native extension ruby 1.8.7

Working on an outdated project that I need to debug but can't manage to install debugger. 处理我需要调试但无法安装调试器的过时项目。

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.

The issue is preventing me from debugging some failing specs. 问题是阻止我调试一些失败的规范。 Any help would be greatly appreciated! 任何帮助将不胜感激!

It seems like debugger is for Ruby 1.9.2 & 1.9.3, and that ruby-debug might be better suited for Ruby 1.8. 似乎调试器适用于Ruby 1.9.2和1.9.3,而ruby-debug可能更适合Ruby 1.8。

You could try using ruby-debug with: 您可以尝试使用ruby-debug

gem install ruby-debug

From the README: 来自README:

There are two ways of running ruby-debug. 运行ruby-debug有两种方法。

rdebug executable: rdebug可执行文件:

$ rdebug <your-script>

When you start your script this way, the debugger will stop at the first line of code in the script file. 以这种方式启动脚本时,调试器将停在脚本文件的第一行代码中。 So you will be able to set up your breakpoints. 因此,您将能够设置断点。

ruby-debug API ruby-debug API

The second way is to use the ruby-debug API to interrupt your code execution at run time. 第二种方法是使用ruby-debug API在运行时中断代码执行。

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

or 要么

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

When Kernel#debugger method is executed, the debugger is activated and you will be able to inspect and step through your code. 执行Kernel#debugger方法时,调试器将被激活,您将能够检查并逐步执行代码。

Alternatively, you could move 'debugger' into the development block in your Gemfile: 或者,您可以将“调试器”移动到Gemfile中的开发块中:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM