简体   繁体   中英

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.

You could try using ruby-debug with:

gem install ruby-debug

From the README:

There are two ways of running ruby-debug.

rdebug executable:

$ 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

The second way is to use the ruby-debug API to interrupt your code execution at run time.

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.

Alternatively, you could move 'debugger' into the development block in your Gemfile:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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