how do I install ruby-debug in ruby 1.9.3 / Rails 3.2.1 [duplicate]
Asked Answered
D

2

14

Possible Duplicate:
Rails 3.1 and Ruby 1.9.3p125: ruby-debug19 still crashes with “Symbol not found: _ruby_threadptr_data_type”

I'm done with printing to the console -- I want to move up to the 20th century and start using a debugger!! But how do I install ruby-debug? The native compilation of ruby-debug.c fails when I try to install the ruby-debug19 gem. I've looked over other SO postings and haven't found the answer yet...

  • I am using Ruby 1.9.3-p0
  • I am using Rails 3.2 (with Gemfile, of course)
  • I am NOT using RVM -- instead, I have a fully sandboxed directory containing all executables, gems, sources, etc. I refer to it as $SANDBOX below...

bundle install doesn't work

If I add ruby-debug19 to my Gemfile and do bundle install, it fails during build with conflicting types for 'rb_iseq_compile_with_option':

# file: Gemfile
...
group :development do
  gem 'ruby-debug19'
end
...

% bundle install
...
Installing ruby-debug-base19 (0.11.25) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
        /Users/r/Developer/Topaz/usr/bin/ruby extconf.rb 
...
ruby_debug.c:29: error: conflicting types for 'rb_iseq_compile_with_option'
$SANDBOX/usr/include/ruby-1.9.1/ruby-1.9.3-p0/vm_core.h:505: error: previous declaration of 'rb_iseq_compile_with_option' was here
...
make: *** [ruby_debug.o] Error 1

gem install ruby-debug from the command line doesn't work

If I try building the gem from the command line, using the --with-ruby-include argument pointing at the include directory for the current ruby, I get the same error:

% gem install ruby-debug19 -- --with-ruby-include=$SANDBOX/packages/ruby-1.9.3-p0
Building native extensions.  This could take a while...
ERROR:  Error installing ruby-debug19:
        ERROR: Failed to build gem native extension.

        $SANDBOX/usr/bin/ruby extconf.rb --with-ruby-include=$SANDBOX/packages/ruby-1.9.3-p0/include
checking for rb_method_entry_t.body in method.h... no
checking for vm_core.h... yes
checking for iseq.h... yes
checking for insns.inc... yes
checking for insns_info.inc... yes
checking for eval_intern.h... yes
creating Makefile

make
compiling breakpoint.c
compiling ruby_debug.c
ruby_debug.c:29: error: conflicting types for 'rb_iseq_compile_with_option'
$SANDBOX/usr/include/ruby-1.9.1/ruby-1.9.3-p0/vm_core.h:505: error: previous declaration of 'rb_iseq_compile_with_option' was here

what am I missing?

Is --with-ruby-include expecting something different? Is the current ruby-debug19 broken?

Discomposure answered 3/2, 2012 at 0:46 Comment(7)
A google search indicates that a lot of people have had issues with the debugger on 1.9.3. There seem to be a few hacks to make it work: gist.github.com/1331533 blog.wyeworks.com/2011/11/1/ruby-1-9-3-and-ruby-debugMaquis
@Marc: Between the two of those links, I got it to work. See my answer below.Discomposure
Hi @casperOne -- just curious: this question was posted prior to #9442700 -- according to the FAQ, shouldn't it be that one that gets closed as a duplicate?Discomposure
@fearless no, post time does not cometely dictate which question is a dupe of another.Tagmeme
@casperOne: I'm not arguing, but still curious. Quoting from the FAQ: "exact duplicate: This question covers exactly the same ground as earlier questions on this topic; its answers may be merged with another identical question." What was your basis for marking this as an exact duplicate? (Someday I'll have close privs and want to learn the ropes...)Discomposure
@casperOne: would you consider closing #9442700 rather than this one? Because: this one was first; it has gotten far more views; the subject is is clear in its intent; the answer (IMO) is much easier to follow. (But I'm biased -- anyone else want to weigh in?)Discomposure
There is a better alternative. See https://mcmap.net/q/145852/-debugging-in-ruby-1-9Hardihood
D
19

Thanks to @Marc Talbot's comment in the OP, I found a working recipe.

download linecache19 and ruby-debug-base19 from RubyForge:

% curl -OL http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
% curl -OL http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem

compile the two gems

% gem install linecache19-0.5.13.gem
Building native extensions.  This could take a while...
Successfully installed linecache19-0.5.13
1 gem installed
...
% gem install ruby-debug-base19-0.11.26.gem -- --with-ruby-include=$SANDBOX/packages/ruby-1.9.3-p0
Building native extensions.  This could take a while...
Successfully installed ruby-debug-base19-0.11.26
1 gem installed
...

update your Gemfile

# file: Gemfile
...
group :development do
  gem 'linecache19', '0.5.13'
  gem 'ruby-debug-base19', '0.11.26'
  gem 'ruby-debug19', :require => 'ruby-debug'
end

bundle install and test the debugger

% bundle install
Fetching source index for http://rubygems.org/
...
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
% irb
irb(main):001:0> require 'ruby-debug'
=> true
irb(main):002:0> debugger
$SANDBOX/usr/lib/ruby/1.9.1/irb/context.rb:166
@last_value = value
(rdb:1) p 'hooray'
"hooray"

Hopefully this will help others.

Discomposure answered 3/2, 2012 at 5:30 Comment(4)
These steps worked for me. To make this work through an IDE (like Netbeans), however, you need to do gem install --ignore-dependencies -v 0.4.12 ruby-debug-ide19 afterwards.Blastogenesis
This method worked for me in Windows 7 also. If you don't have curl, you can just copy those gem urls and paste it in a web browser to download it. Then change directory to the download path before executing gem install. I had to change --with-ruby-include=$SANDBOX/packages/ruby-1.9.3-p0 to <MY_RUBY_INSTALLATION_PATH>/include/ruby-1.9.1/ruby-1.9.3-p<RELEASE_NUMBER>Hujsak
I just read from another SO discussion that ruby-debug19 is no longer actively maintained. see: https://mcmap.net/q/145852/-debugging-in-ruby-1-9 It is recommended to use the new debugger gem : github.com/cldwalker/debuggerHujsak
group :deployment do gem 'linecache19', '0.5.13' gem 'ruby-debug-base19x', '>= 0.11.30.pre10' gem 'ruby-debug19', :require => 'ruby-debug' endDepravity
G
2

(From your logs, I assume you are on Linux, specifically a Debian distro) There is a simple solution to this: In the shell,

sudo apt-get install ruby-dev1.9.3

Note: I don't actually know if there is a package called ruby-dev1.9.3, because I installed ruby-dev for 1.9.2, which was ruby-dev1.9 (I think. That was a while ago. If anyone knows what they are, please comment).

This package installs the headers that the C extensions to the interpreter need (ruby.h).

Gripsack answered 3/2, 2012 at 2:0 Comment(2)
FWIW, I'm on Mac OS X 10.6.8, so I don't use apt-get. I downloaded and compiled my ruby sources from ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p0.tar.gz. My un-tar'd source tree has include/ruby.h and include/ruby/ruby.h.Discomposure
For me the key was linecache19 v0.5.13Witmer

© 2022 - 2024 — McMap. All rights reserved.