ruby-debug with Ruby 1.9.3?
Asked Answered
A

9

70

I just updated to Ruby 1.9.3p0 and Rails 3.1.1. Now when I try to launch the server, it complains that I should install ruby-debug, even though it's already installed.

% rails server --environment=development --debug
=> Booting WEBrick
=> Rails 3.1.0 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug'
Exiting

In my Gemfile I have

# see: https://mcmap.net/q/145852/-debugging-in-ruby-1-9
gem 'ruby-debug-base19', "0.11.24"
gem 'ruby-debug19', "0.11.6"

Is it possible to run debug with the latest version of Ruby?

Approach answered 10/11, 2011 at 23:1 Comment(1)
Yes. https://mcmap.net/q/145852/-debugging-in-ruby-1-9Ludicrous
F
102

Update (April 28, 2012)

Try the new debugger gem as a replacement for ruby-debug.

(credit to @ryanb)


Update (March 2, 2012)

Installation of linecache19 and ruby-debug-base19 can be easily done with:

bash < <(curl -L https://raw.github.com/gist/1333785)

(credit to @fredostarr)


Original answer

Have you looked at ruby-debug19 on ruby-1.9.3-preview1?

Here's a temporary solution: http://blog.wyeworks.com/2011/11/1/ruby-1-9-3-and-ruby-debug

Excerpt from the site:

First download linecache19-0.5.13.gem and ruby-debug-base19-0.11.26.gem from http://rubyforge.org/frs/?group_id=8883, then …

$ 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=/Users/santiago/.rbenv/source/ruby-1.9.3-p0  
Building native extensions.  This could take a while...
Successfully installed ruby-debug-base19-0.11.26
1 gem installed
$ irb
irb(main):001:0> require 'ruby-debug'
=> true
Felicity answered 11/11, 2011 at 1:4 Comment(5)
The problem with this approach is that these steps circumvent the Gemfile, adding a manual step before running bundle install. I've written up a solution that allows you run bundler normally here: git.io/72UfQgBegorra
Try the new "debugger" gem: gem 'debugger' github.com/cldwalker/debuggerStraight
Update: I've packaged these gems and put them on gemfury. If using bundler, it's nice to have the --with-ruby-include remembered.Hafnium
Debugger is awesome. This works. Mine answer hath jumped on own sword.Hafnium
Here's how I was able to install it on my local box for rvm Ruby 1.9.3 :- gist.github.com/4132084. Hth..Lockett
G
33

Installation of linecache19 and ruby-debug-base19 can be easily done with:

bash < <(curl -L https://raw.github.com/gist/1333785)
Graphite answered 25/11, 2011 at 10:58 Comment(3)
As well as this, for it to work in rails, I needed to add to my Gemfile gem 'linecache19', '>= 0.5.13' gem 'ruby-debug-base19', '>= 0.11.26' gem 'ruby-debug19'Kwangchow
Try the new "debugger" gem: gem 'debugger' github.com/cldwalker/debuggerStraight
@Straight Thank you kind sir! I was dreading trying to get rdebug working with 1.9.3 (and delayed_job was causing havoc with 1.9.2-p290)Yung
E
5

Someone else posted in a comment to try Pry, which is what I did. This is what's necessary for Rails:

# Gemfile
gem 'pry-rails'


# In your Rails Project where you want a 'debugger'

puts 'i want to insert some code between this'

binding.pry

puts 'and this'

Immediately after installing I notice my .irbrc doesn't load, so I don't get pretty console output. I also added this to my '~/.pryrc'

# setting up pry to have irb helpers like reload!
if defined?(Rails) && Rails.env
  extend Rails::ConsoleMethods
end

Pry has some nice features that I've wanted to check out, and I may yet return to ruby-debug once there's a simple way to integrate it into a Rails project for Ruby 1.9.3. I can run the curl command from the other answers, but this is something I'll have to point my teammates to for our Rails project, so it doesn't scale well IMO.

Enucleate answered 3/3, 2012 at 1:19 Comment(0)
R
4

Maybe not the definitive answer to this question, but I was lead here by a chain of closed duplicates.

For me the problem was that I run a project in both ruby 1.8 and ruby 1.9, and my Gemfile needed this change:

gem 'debugger', :require => 'ruby-debug', :platforms => :mri_19
gem 'ruby-debug', :platforms => :mri_18

Now it works for both rubies.

For more info see here: http://gembundler.com/man/gemfile.5.html#PLATFORMS-platforms-

Reseta answered 28/8, 2012 at 15:16 Comment(0)
I
2

For Windows Users:

First Download :linecache19-0.5.13.gem and ruby-debug-base19-0.11.26.gem From : http://rubyforge.org/frs/?group_id=8883&release_id=46303

Assumption: Ruby is in c:\Ruby1.93

put the gem files downloaded to c:\temp (linecache19-0.5.13.gem and ruby-debug-base19-0.11.26.gem)

then execute from command line:

gem install c:\temp\linecache19-0.5.13.gem

gem install c:\temp\ruby-debug-base19-0.11.26.gem -- --with-ruby-include=C:\Ruby1.93\include\ruby-1.9.1\ruby-1.9.3-p0

Inefficacious answered 26/1, 2012 at 1:45 Comment(1)
The default path for Ruby Installer is C:\Ruby193. Also, this requires the DevKit.Hafnium
U
1

BTW, if you use the newest patch for ruby1.9.3 (falcon, https://gist.github.com/1688857), use following commands

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

gem install linecache19-0.5.13.gem
## with rvm: 
gem install ruby-debug-base19-0.11.26.gem -- --with-ruby-include=$HOME/.rvm/src/ruby-1.9.3-p0-falcon
## with rbenv (this is a guess): 
gem install ruby-debug-base19-0.11.26.gem -- --with-ruby-include=$HOME/.rbenv/source/ruby-1.9.3-p0-falcon
Unwinking answered 29/1, 2012 at 21:4 Comment(3)
Is anyone known to run this in production?Hafnium
well. I would not trust it to run any big site... had too many slight edge-cases and this is just to bleeding-edge. wait a couple of months, most bugs should be ironed out till then. cheers!Unwinking
Checked around: Falcon patch and friends are pretty awesome for speeding up local dev at least.Hafnium
M
1

See my answer here : Ruby-debug not working - Stack Overflow

It's about getting Ruby debugging to work with the following setup

  • Mac OS X Lion 10.7.2
  • Aptana Studio 3 (Build 3.0.8.201201201658)
  • Using rvm, in my project working directory I have a .rvmrc stating:

    rvm use ruby-1.9.3-p0@mygemset
    

Basically, I had to use :

linecache19 (0.5.13)
ruby-debug-base19x (0.11.30.pre10)
ruby-debug-ide (0.4.16)

Note that I'm not using ruby-debug-base19 but ruby-debug-base19x

I hope this helps!

-- Freddy

Mendymene answered 13/2, 2012 at 13:2 Comment(0)
B
0

Also you need to check if the gem 'ruby_source_code' is already installed.

Check: http://bugs.ruby-lang.org/issues/1857#note-8

Beare answered 29/12, 2011 at 1:43 Comment(0)
P
0

If you don't have rvm and assuming you ruby installation is in /usr/local/ruby-1.9.3-po your can use this command:

curl -L https://raw.github.com/gist/1533750 | sudo /bin/bash

Patella answered 29/12, 2011 at 12:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.