52

I have standard ruby-head and Rails 3.1rc4. I installed ruby-debug with following instructions from http://dirk.net/2010/04/17/ruby-debug-with-ruby-19x-and-rails-3-on-rvm/

But when i run rails s --debugger it will throw this strange error

/Users/schovi/.rvm/gems/ruby-head/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:237:in `require': dlopen(/Users/schovi/.rvm/gems/ruby-head/gems/linecache19-0.5.12/lib/trace_nums19.bundle, 9): Symbol not found: _ruby_current_thread (LoadError)
  Referenced from: /Users/schovi/.rvm/gems/ruby-head/gems/linecache19-0.5.12/lib/trace_nums19.bundle
  Expected in: flat namespace
in /Users/schovi/.rvm/gems/ruby-head/gems/linecache19-0.5.12/lib/trace_nums19.bundle - /Users/schovi/.rvm/gems/ruby-head/gems/linecache19-0.5.12/lib/trace_nums19.bundle
from /Users/schovi/.rvm/gems/ruby-head/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:237:in `block in require'
from /Users/schovi/.rvm/gems/ruby-head/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:223:in `block in load_dependency'

Any idea? Thanks, David

Schovi
  • 1,960
  • 5
  • 19
  • 33

7 Answers7

54

UPDATE:

Looks like you only need to put this in your gemfile:

gem "debugger"

and now works.

Old article follows

====================================

Jerome is correct, but lacking in the details. Here is the blow by blow, taken from this https://gist.github.com/1331533, in particular thanks to andrewroth's post. I've tested this as of the time of this post. One hopes that the changes will be deployed somewhere standard soon.

Installing ruby debugger on ruby 1.9.3-p125: 

export PATCH_LEVEL=`ruby -e 'puts RUBY_PATCHLEVEL'`
export RVM_SRC=$HOME/.rvm/rubies/ruby-1.9.3-p$PATCH_LEVEL/include/ruby-1.9.1
gem install archive-tar-minitar
gem install ruby_core_source -- --with-ruby-include=/$RVM_SRC
export RVM_SRC=$HOME/.rvm/rubies/ruby-1.9.3-p$PATCH_LEVEL/include/ruby-1.9.1/ruby-1.9.3-p$PATCH_LEVEL

wget http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem
wget http://rubyforge.org/frs/download.php/63094/ruby-debug19-0.11.6.gem
wget http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
gem install linecache19-0.5.13.gem -- --with-ruby-include=/$RVM_SRC
# if that step failed, and you are running OSX Lion, then following this post can help you: 
# http://stackoverflow.com/questions/8032824/cant-install-ruby-under-lion-with-rvm-gcc-issues
# this happens if you recently installed xcode from the app store. 
# bizarrely, for me I had to do this: ln -s /usr/bin/gcc /usr/bin/gcc-4.2
gem install ruby-debug-base19-0.11.26.gem -- --with-ruby-include=/$RVM_SRC

Then edit Gemfile: 

gem 'linecache19', '0.5.13', :path => "~/.rvm/gems/ruby-1.9.3-p#{RUBY_PATCHLEVEL}/gems/linecache19-0.5.13/"
gem 'ruby-debug-base19', '0.11.26', :path => "~/.rvm/gems/ruby-1.9.3-p#{RUBY_PATCHLEVEL}/gems/ruby-debug-base19-0.11.26/"
gem 'ruby-debug19', :require => 'ruby-debug'

Then install: 

bundle install
Rob
  • 4,404
  • 2
  • 32
  • 33
  • I did everything in Rob's post, but the gem installs failed. I had to do the following in the directory where the gem was downloaded: rvm 1.9.3-p0@mygemset do gem install ~/Downloads/linecache19-0.5.13.gem -- --with-ruby-include=/Users//.rvm/src/ruby-1.9.3-p0 rvm 1.9.3-p0@mygemset do gem install ~/Downloads/ruby-debug-base19-0.11.26.gem -- --with-ruby-include=/Users//.rvm/src/ruby-1.9.3-p0 I'm running OSX Lion 10.7.3 – seanmrafferty Feb 15 '12 at 16:47
  • I did everything in Rob's post, but the gem installs failed. I had to do the following in the directory where the gem was downloaded: rvm 1.9.3-p0@mygemset do gem install ~/Downloads/linecache19-0.5.13.gem -- --with-ruby-include=/Users//.rvm/src/ruby-1.9.3-p0 rvm 1.9.3-p0@mygemset do gem install ~/Downloads/ruby-debug-base19-0.11.26.gem -- --with-ruby-include=/Users//.rvm/src/ruby-1.9.3-p0 I'm running OSX Lion 10.7.3 – seanmrafferty Feb 15 '12 at 18:22
  • After a good bit of going back and forth with different blog posts on how to get debugger working this did the trick :) – stcorbett Feb 18 '12 at 03:27
  • @seanmrafferty - you were right, I missed the wget for linecache gem, added that and updated for 1.9.3-p125 – Rob Feb 21 '12 at 22:54
  • Good tip. I successfully start with debugger with above instructions. thanks! – shigeya Mar 02 '12 at 06:10
  • trying to understand --with-ruby-include what is that for? and why do we need different RVM_SRC for different packages? thanks... – Robert A Henru Jun 09 '12 at 11:04
  • I just had to switch to `gem 'debugger'` in my Gemfile, and I'm running again. Mac OS X Lion, ruby 1.9.3-p125 – Tim Harper Apr 16 '13 at 00:15
  • this worked for me, but I had to remove gem "ruby-debug19" from the Gemfile – Sam Joseph May 08 '13 at 13:21
21

I used the gem 'debugger' which is a fork of ruby-debug(19) that works on 1.9.2 and 1.9.3 and installs easily for rvm/rbenv rubies. It makes the error disappear !

Mustafah
  • 4,447
  • 2
  • 24
  • 24
11

It looks like this is a known bug in ruby-debug-base, for the moment. I have added my comment to the issue on the bug tracker. Plase consider adding your notes as well:

http://rubyforge.org/tracker/index.php?func=detail&aid=29222&group_id=8883&atid=34290

In the meantime, ruby 1.9 has a built-in debugger; its just very slow. Manually add this require line to your code:

require 'debug'

Also, the debugger breaks on all StandardError exceptions by default, so do this when it first starts up:

catch off
Travis Warlick
  • 644
  • 4
  • 14
6

If you are running Ruby 1.9.3x, to fix it go to ruby-debug on rubyforge, download and install ruby-debug-base 0.11.26 and linecache19 0.5.13. Modify your Gemfile to use these files, then run

bundle update ruby-debug-base19

Debugger should work now.

Thanks Jerome

WispyCloud
  • 4,140
  • 1
  • 28
  • 31
  • 2
    ruby-debug-base19 v 0.11.26 did not compile on my system (with rvm). I had to add the ruby includes to make it compile: gem install ruby-debug-base19-0.11.26.gem -- --with-ruby-include=~/.rvm/rubies/ruby-1.9.3-p0/include/ruby-1.9.1/ruby-1.9.3-p0/ – Joris Feb 07 '12 at 15:39
  • Did not work for me, the update went fine but still same error :( Error Output: Fast Debugger (ruby-debug-ide 0.4.17.beta8, ruby-debug-base 0.11.30.pre7) listens on 127.0.0.1:60534 – Rubytastic Feb 14 '12 at 20:56
  • This work for me gem install ruby-debug-base19-0.11.26.gem -- --with-ruby-include=/Users/jirapong/.rvm/src/ruby-1.9.3-p0 . take from https://gist.github.com/1331533 – Jirapong Oct 19 '12 at 09:27
0

Using ruby 1.9.3, I was able to get this to work by adding the gem 'ruby-debug-base19x' (note the 'x' at the end of the name) in addition to 'ruby-debug19'.

EK0
  • 305
  • 5
  • 16
0

My system is rvm 1.18.10 and ruby 1.9.3p392 on Mac OSX 10.8.5. I first installed gem 'ruby-debug19', but for the well-known reason, the debugger did not work.

I then ran

local$ gem install 'debugger'

as suggested by many other posts. The gem was installed successfully with the following outputs:

local$ gem install debugger
Fetching: debugger-ruby_core_source-1.2.3.gem (100%)
Fetching: debugger-linecache-1.2.0.gem (100%)
Fetching: debugger-1.6.2.gem (100%)
Building native extensions.  This could take a while...
Successfully installed debugger-ruby_core_source-1.2.3
Successfully installed debugger-linecache-1.2.0
Successfully installed debugger-1.6.2
3 gems installed
Installing ri documentation for debugger-ruby_core_source-1.2.3...
Installing ri documentation for debugger-linecache-1.2.0...
Installing ri documentation for debugger-1.6.2...
Installing RDoc documentation for debugger-ruby_core_source-1.2.3...
Installing RDoc documentation for debugger-linecache-1.2.0...
Installing RDoc documentation for debugger-1.6.2...
local$ irb
1.9.3-p392 :002 > require 'debugger'
=> true

I then ran

local$ rails server --debug
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:
in`require': dlopen(/usr/local/rvm/gems/ruby-1.9.3-p392/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle,
9): Symbol not found: _ruby_current_thread (LoadError)
Referenced from: /usr/local/rvm/gems/ruby-1.9.3-p392/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle
Expected in: flat namespace
 in /usr/local/rvm/gems/ruby-1.9.3-p392/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle - /usr/local/rvm/gems/ruby-1.9.3-p392/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle
......

I resolved this error by commenting out the line "gem 'ruby-debug19'" and adding a new line "gem 'debugger'" in the Gemfile, and then ran

local$ bundle update

After that, everything worked fine.

local$ rails server --debug
=> Booting WEBrick
=> Rails 3.2.14 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
=> Debugger enabled
[2013-10-15 12:50:21] INFO  WEBrick 1.3.1
[2013-10-15 12:50:21] INFO  ruby 1.9.3 (2013-02-22) [x86_64-darwin10.8.0]
[2013-10-15 12:50:21] INFO  WEBrick::HTTPServer#start: pid=7206 port=3000
Julia Zhao
  • 899
  • 1
  • 6
  • 11
0

This was fixed upgrading to the latest gems of all debug

Rubytastic
  • 15,001
  • 18
  • 87
  • 175
  • Still not working for me. What version of ruby-debug19 and linecache19 are you using that works? – jasoncrawford Mar 21 '12 at 20:55
  • These are in my dev group: you won't need them all check versions for the debug ones: group :development do gem "sunspot_solr" # optional pre-packaged Solr distribution for use in development gem "annotate" gem "faker" gem "populator" gem "erb2haml" gem "foreman" gem "progress_bar" gem "simplecov" gem "ruby-debug19" gem 'ruby-debug-base19x', '0.11.30.pre10' gem "ruby-debug-ide", '0.4.17.beta8' #gem 'newrelic_rpm' gem "capistrano" gem "bundler" end – Rubytastic Mar 21 '12 at 22:42