Unable to debug in RubyMine 4.5 using Ruby 1.9.3

18,991

Solution 1

UPDATE: RubyMine 6+ supports debugger gem.

Make sure to remove gem 'debugger' from your Gemfile, it's a known conflict that will break debugging from RubyMine. You need only 2 gems related to debugger, exactly as stated in my another answer linked in your question.

After removing the gem you need to ensure it's not referenced anywhere in the project. In this particular case r_spec_runner.rb had require 'ruby-debug' statement causing cannot load such file -- ruby-debug error when trying to run rails console.

Solution 2

To escape this problem I have this line in my Gemfile:
gem 'debugger' unless ENV["RM_INFO"]

Solution 3

Just to document the solution from jetbrains: Use either:

gem 'debugger', {group: [:test, :development]}.merge(ENV['RM_INFO'] ? {require: false} : {})

Or:

gem 'pry-debug', {group: [:test, :development]}.merge(ENV['RM_INFO'] ? {require: false} : {})

This makes sure that the Gemfile.lock remains unchanged, so a group with mixed RubyMine and vi/sublime/whatever can work happily, by do not requiring the gem in a RubyMine environment.

Solution 4

I had the same issue, and it cost me hours to get it working. Here is what finally got the debugger going (this is using RVM):

  • Quit RubyMine
  • If Ruby 1.9.3 is installed, uninstall it: rvm remove 1.9.3
  • Install Ruby 1.9.3 under RVM: rvm install 1.9.3 --with-gcc=clang - this produces the error "unsupported option '--with-libyaml'", but I haven't seen any ill effects from this yet
  • Switch to the new ruby: rvm use 1.9.3
  • List and remove all ruby-debug* gems: gem list | grep debug - gem uninstall <found gems>
  • Download linecache19 from http://rubyforge.org/frs/?group_id=8883 and install the gem, i.e.: gem install linecache19-0.5.13.gem
  • Lauch RubyMine, and run the debugger; it will inform about missing debug gems (i.e. ruby-debug-ide); let RubyMine install those.

That's when the debugger started working. See also this RubyMine support discussion: http://devnet.jetbrains.com/message/5443846#5443846

Share:
18,991

Related videos on Youtube

rwb
Author by

rwb

Updated on July 13, 2022

Comments

  • rwb
    rwb almost 2 years

    My apologies for the length of the question, but I want to make it clear I am not making any stupid mistakes!

    So, I am struggling to get debugging working in RubyMine 4.5 using Ruby 1.9.3, my steps are as follows:

    Fresh (i.e. having removed all previous ruby and gem directories) install of Ruby 1.9.3, Ruby Gems, DevKit and Rails (following this guide) - that works fine.

    I then try to begin working with my team's ruby code. I open up the directory in RubyMine (remembering first to delete the .idea directory) and am prompted to run bundle install which I do (from console) as requested. This completes successfully. Restart RubyMine.

    I then ensure Ruby is working: Tools > IRB Console > puts "test" #test => nil - Works I now try the debugger (SHIFT + F9) and see the message:

    The gem ruby-debug-base19x required by the debugger is currently not installed. Would you like to install it?"

    I click cancel and check my Gemfile, the only ones related to debugging present are:

    # Debugging
    gem 'debugger'
    #gem 'ruby-debug-base19', :require => false
    #gem 'ruby-debug19', :require => false
    gem 'ruby-prof', :require => false #, :git => 'git://github.com/wycats/ruby-prof.git'
    

    Looks like we have debugger in favour of ruby-debug. Reading here, however, it seems debugger is not sufficient. I need to install ruby-debug-base19x. So, following SO, I comment out debugger from Gemfile and run

    gem install ruby-debug-base19x --pre
    gem install ruby-debug-ide --pre
    

    Which run fine, so I add

    gem 'ruby-debug-base19x', '0.11.30.pre10'
    gem 'ruby-debug-ide', '0.4.17.beta14'
    

    to my Gemfile, and run a bundle install from the console.

    Finally, i open the debugger inside RubyMine (SHIFT + F9). And puts "test" #test => nil works again. So i try double clicking in the gutter of my script to create a breakpoint, RubyMine pauses for a second and then i get:

    D:\Ruby\Ruby193\bin\ruby.exe -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/ruby-debug-ide-0.4.17.beta14/bin/rdebug-ide --dispatcher-port 55451 --port 55452 -- S:/code/account_groups/script/rails console
    Fast Debugger (ruby-debug-ide 0.4.17.beta14, ruby-debug-base 0.11.30.pre10) listens on 127.0.0.1:55452
    D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/debugger-1.1.4/lib/ruby_debug.so: warning: already initialized constant VERSION
    5992: Exception in DebugThread loop: undefined method `errmsg' for #<Debugger::ControlState:0x2a2f3e8>
    Backtrace:
    D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/debugger-1.1.4/lib/ruby-debug/command.rb:160:in `errmsg'
      from: D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/debugger-1.1.4/lib/ruby-debug/commands/breakpoints.rb:81:in `execute'
      from: D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/ruby-debug-ide-0.4.17.beta14/lib/ruby-debug-ide/ide_processor.rb:89:in `block in process_commands'
      from: D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/ruby-debug-ide-0.4.17.beta14/lib/ruby-debug-ide/ide_processor.rb:86:in `catch'
      from: D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/ruby-debug-ide-0.4.17.beta14/lib/ruby-debug-ide/ide_processor.rb:86:in `process_commands'
      from: D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/ruby-debug-ide-0.4.17.beta14/lib/ruby-debug-ide.rb:160:in `block in start_control'
    
    Process finished with exit code 0
    

    I have also tried using a backup copy of the code and following the same steps, i also get the following error when trying to load up the debugger:

    Uncaught exception: cannot load such file -- ruby-debug
        D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `require'
        D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `block in require'
        D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:236:in `load_dependency'
        D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `require'
        S:/code/account_groups_so/lib/systematic-online/r_spec_runner.rb:5:in `<top (required)>'
        D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `require'
        D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `block in require'
        D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:236:in `load_dependency'
        D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `require'
        S:/code/account_groups_so/config/environment.rb:12:in `block in <top (required)>'
        S:/code/account_groups_so/config/environment.rb:12:in `each'
        S:/code/account_groups_so/config/environment.rb:12:in `<top (required)>'
        D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `require'
        D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `block in require'
        D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:236:in `load_dependency'
        D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `require'
        D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/application.rb:103:in `require_environment!'
        D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/commands.rb:40:in `<top (required)>'
        S:/code/account_groups_so/script/rails:6:in `require'
        S:/code/account_groups_so/script/rails:6:in `<top (required)>'
    

    There is nothing wrong with the script (i have used it fine before) and the trace seems related to ruby-debug-ide - what's going on?

    Thanks for any help - this is driving me mad!

    • CrazyCoder
      CrazyCoder almost 12 years
      Please provide a small sample project to reproduce this issue.
    • rwb
      rwb over 11 years
      Thanks for the response, but I'm not sure what you want me to provide? I can give you my full Gemfile, Gemfile.lock or print out my Ruby ENV?
    • CrazyCoder
      CrazyCoder over 11 years
      Zip and share the directory with the sample script, RubyMine project (.idea directory) which will show where breakpoint is set, Gemfile, Gemfile.lock.
    • rwb
      rwb over 11 years
      I am reluctant to upload my script as it is IP of my company (and it is not the issue). I have updated and expanded by my question with new symptoms as I have somehow overcome the previous error and now am back to an error I had before (i have re-installed numerous times today!) Does that help?
    • CrazyCoder
      CrazyCoder over 11 years
      Do you mean that the bug is specific to this particular script that you can's share and there is no way you can reproduce this problem with any other script?
    • rwb
      rwb over 11 years
      No. It is in no way specific to the script. This happens with any .rb file on my installation of RubyMine. I believe the issue is incompatible debug gems. I will do another fresh install and attempt to rephrase the question (I have seen so many errors, I am not sure which to include - hence the confusion above).
    • CrazyCoder
      CrazyCoder over 11 years
      You can prepare and share a dummy project with similar configuration and any script that is not protected by your IP.
    • rwb
      rwb over 11 years
  • rwb
    rwb over 11 years
    I have done. I comment out gem 'debugger', install the two debug gems and then add them to my gemfile and finally bundle update
  • CrazyCoder
    CrazyCoder over 11 years
    Note that since RubyMine 4.5 you can disable debugger gem related code like this: gem "debugger" unless ENV["RM_INFO"].
  • Jason
    Jason over 11 years
    Can't seem to download 0.5.13 any more. Page load times out. I don't understand how RM is shipping without the debugger working.
  • orbiteleven
    orbiteleven over 11 years
    AFAIK this won't affect the Gemfile.lock so folks using RubyMine still get borked
  • crizCraig
    crizCraig about 11 years
    I ran gem build gem build linecache19-0.5.13.gemspec after git clone [email protected]:robmathews/linecache19-0.5.13 Here's the file if you trust me :) dl.dropbox.com/u/9632169/linecache19-0.5.13.gem
  • CrazyCoder
    CrazyCoder about 11 years
  • shadowbrush
    shadowbrush about 11 years
    I haven't had any issues with RubyMine 5. Seems to work out of the box after it installed the gems it needed.
  • Jeff Cutler-Stamm
    Jeff Cutler-Stamm about 11 years
    For those still having problems after following this answer, if you are on Mac OSX make sure your computer name is set in System Preferences | Sharing. It took me forever to figure this out. More detail here: youtrack.jetbrains.com/issue/RUBY-8990
  • Donato
    Donato almost 9 years
    As soon as I commented out gem 'debugger' in my Gemfile, it started working.
  • K.Nicholas
    K.Nicholas about 8 years
    More of a comment than an answer. Pls consider making this a comment.