In the Gemfile of a new Rails 3 application,
this section is commented out by default:
Gemfile
123
...# To use debugger# gem 'ruby-debug19', :require => 'ruby-debug'
Uncommenting the last line will install ruby-debug19
and dependencies (including linecache19).
However, in the combination of rvm with ruby 1.9.3 on Ubuntu
this fails. The bundle install command hangs forever on
the installation of linecache19 (until interrupted with Control-C):
12345678
$ bundle install
Fetching source index for http://rubygems.org/
Using rake (0.9.2.2)...
Installing linecache19 (0.5.12) with native extensions
^C
Interrupt: An error occured while installing linecache19 (0.5.12), and Bundler cannot continue.
Make sure that `gem install linecache19 -v '0.5.12'` succeeds before bundling.
The root cause of the problem was not clear, but I was able to
make this pass with a “manual” gem install of linecache19 and
ruby-debug-base19 with an explicit include of an extra source
directory:
12345678910111213141516171819
$ gem install linecache19 -- --with-ruby-include=$rvm_path/src/ruby-1.9.3-p0
Building native extensions. This could take a while...
Successfully installed linecache19-0.5.12
1 gem installed
$ bundle install
Fetching source index for http://rubygems.org/
...
Installing ruby-debug-base19 (0.11.25) with native extensions ^C
Interrupt: An error occured while installing ruby-debug-base19 (0.11.25), and Bundler cannot continue.
Make sure that `gem install ruby-debug-base19 -v '0.11.25'` succeeds before bundling.
...
$ gem install ruby-debug-base19 -- --with-ruby-include=$rvm_path/src/ruby-1.9.3-p0
Building native extensions. This could take a while...
Successfully installed ruby-debug-base19-0.11.25
1 gem installed
$ bundle install
...
Your bundle is complete! ...
$
Once this hurdle is passed, a second problem arises …
The currently published versions of ruby-debug-base and linecache19
12
ruby-debug-base19 (0.11.25)linecache19 (0.5.12)
raise exceptions on Rails on ruby 1.9.3
123456
.../gems/ruby-debug-base19-0.11.25/lib/ruby-debug-base.rb:1:in `require':.../gems/ruby-debug-base19-0.11.25/lib/ruby_debug.so: undefined symbol: ruby_current_thread -.../gems/ruby-debug-base19-0.11.25/lib/ruby_debug.so (LoadError) from .../gems/ruby-debug-base19-0.11.25/lib/ruby-debug-base.rb:1:in `<top (required)>' from .../gems/ruby-debug19-0.11.6/cli/ruby-debug.rb:5:in `require' from .../gems/ruby-debug19-0.11.6/cli/ruby-debug.rb:5:in `<top (required)>'
The solution for this problem is found on a number of blog posts:
gem install those 2 gems from the local Download location, with the above include trick into the current rvm gemset
12345678
$ gem install ~/Downloads/linecache19-0.5.13.gem -- --with-ruby-include=$rvm_path/src/ruby-1.9.3-p0
Building native extensions. This could take a while...
Successfully installed linecache19-0.5.13
1 gem installed
$ gem install ~/Downloads/ruby-debug-base19-0.11.26.gem -- --with-ruby-include=$rvm_path/src/ruby-1.9.3-p0
Building native extensions. This could take a while...
Successfully installed ruby-debug-base19-0.11.26
1 gem installed
force the Gemfile to use these version
12345
# To use debuggergem'linecache19','0.5.13',:path=>"~/.rvm/gems/ruby-1.9.3-p0/gems/linecache19-0.5.13/"gem'ruby-debug-base19','0.11.26',:path=>"~/.rvm/gems/ruby-1.9.3-p0/gems/ruby-debug-base19-0.11.26/"gem'ruby-debug19',:require=>'ruby-debug'
run bundle install
Once these higher level gems are used, using the ruby-debugger works. E.g. in an rspec test spec: