18

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!

Community
  • 1
  • 1
rwb
  • 4,309
  • 8
  • 36
  • 59
  • Please provide a small sample project to reproduce this issue. – CrazyCoder Jul 26 '12 at 16:15
  • 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? – rwb Jul 26 '12 at 16:33
  • Zip and share the directory with the sample script, RubyMine project (`.idea` directory) which will show where breakpoint is set, `Gemfile`, `Gemfile.lock`. – CrazyCoder Jul 26 '12 at 16:35
  • 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? – rwb Jul 26 '12 at 16:46
  • 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? – CrazyCoder Jul 26 '12 at 17:08
  • 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). – rwb Jul 26 '12 at 17:12
  • You can prepare and share a dummy project with similar configuration and any script that is not protected by your IP. – CrazyCoder Jul 26 '12 at 17:24
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/14475/discussion-between-ryan-and-crazycoder) – rwb Jul 26 '12 at 17:33

6 Answers6

18

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.

Community
  • 1
  • 1
CrazyCoder
  • 389,263
  • 172
  • 990
  • 904
  • I have done. I comment out gem 'debugger', install the two debug gems and then add them to my gemfile and finally bundle update – rwb Jul 26 '12 at 17:59
  • 3
    Note that since RubyMine 4.5 you can disable `debugger` gem related code like this: `gem "debugger" unless ENV["RM_INFO"]`. – CrazyCoder Jul 26 '12 at 20:42
  • 1
    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: http://youtrack.jetbrains.com/issue/RUBY-8990 – Jeff Cutler-Stamm Feb 20 '13 at 18:54
  • As soon as I commented out gem 'debugger' in my Gemfile, it started working. – Donato May 23 '15 at 22:25
9

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

code1n
  • 136
  • 1
  • 4
6

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.

JAR.JAR.beans
  • 9,668
  • 4
  • 45
  • 57
3

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

shadowbrush
  • 141
  • 2
  • 2
  • 1
    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. – Jason Nov 09 '12 at 19:26
  • I ran `gem build gem build linecache19-0.5.13.gemspec` after `git clone git@github.com:robmathews/linecache19-0.5.13` Here's the file if you trust me :) https://dl.dropbox.com/u/9632169/linecache19-0.5.13.gem – crizCraig Feb 03 '13 at 08:12
  • I haven't had any issues with RubyMine 5. Seems to work out of the box after it installed the gems it needed. – shadowbrush Feb 15 '13 at 21:55
0

Finally got this working today with a huge kludge hack. I think the step that did it was

  1. sudo chmod -R 777 ~/.rvm

  2. Let RubyMine do its thing

I also made sure to uninstall every gem I had besides rake. I think reby-debug-ide, ruby-debug-base19x, linecache19, ruby_core_source, archive-tar-minitar, and columnize are the important ones. I also uninstalled rvm and reinstalled with clang. But I'd try just doing the chmod thing first. I tried changing to 766, but RubyMine didn't like it. So huge kludge hack it is. I now get lots of warnings about Insecure world but at least the debugger is working. Pretty sure the next version of RubyMine will not use the old ruby-debug-base19x, but instead the more recently edited gems at https://github.com/ruby-debug. So hopefully someone at the awesome JetBrains will fix it. Btw also tried running RubyMine with sudo mine but that didn't do the trick either.

crizCraig
  • 8,487
  • 6
  • 54
  • 53
0

I had some problems with the debugger. I installed Rails and set the path in configuration options to the ruby.exe in the rails installation and everything is working perfect.