无法使用Ruby 1.9.3在RubyMine 4.5中进行调试

时间:2012-07-26 15:00:15

标签: ruby-on-rails ruby rubymine

我对问题的长度表示道歉,但我想说清楚我没有犯任何愚蠢的错误!

所以,我很难使用Ruby 1.9.3在RubyMine 4.5中进行调试,我的步骤如下:

Fresh(即已删除所有以前的ruby和gem目录)安装Ruby 1.9.3,Ruby Gems,DevKit和Rails(在this guide之后) - 工作正常。

然后我尝试开始使用我的团队的红宝石代码。我在RubyMine中打开目录(首先记住删除.idea目录)并提示我按照要求运行bundle install(从控制台)。这成功完成。重启RubyMine。

然后我确保Ruby正在运行:工具> IRB控制台> puts "test" #test => nil - 有效 我现在尝试调试器(SHIFT + F9)并看到消息:

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

我单击取消并检查我的Gemfile,唯一与调试相关的是:

# 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'

看起来我们有调试器支持ruby-debug。但是,阅读here似乎debugger是不够的。我需要安装ruby-debug-base19x。因此,在SO之后,我从Gemfile中注释掉调试器并运行

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

哪个运行正常,所以我添加

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

到我的Gemfile,然后从控制台运行bundle install

最后,我在RubyMine(SHIFT + F9)中打开调试器。 puts "test" #test => nil再次发挥作用。所以我尝试双击我的脚本的阴沟来创建一个断点,RubyMine暂停一秒然后我得到:

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

我也尝试使用代码的备份副本并执行相同的步骤,在尝试加载调试器时也会出现以下错误:

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)>'

脚本没有任何问题(之前我已经使用过了)并且跟踪似乎与ruby-debug-ide有关 - 发生了什么?

感谢您的帮助 - 这让我很生气!

6 个答案:

答案 0 :(得分:17)

更新:RubyMine 6+支持调试器gem。

确保从gem 'debugger'中删除Gemfile,这是一个已知的冲突,会破坏RubyMine的调试。您只需要2个与调试器相关的宝石,完全如您在问题中链接的another answer中所述。

删除gem后,您需要确保它不会在项目中的任何位置引用。在此特定情况下,r_spec_runner.rb在尝试运行require 'ruby-debug'时导致cannot load such file -- ruby-debug错误导致rails console错误。

答案 1 :(得分:9)

为了解决这个问题,我在Gemfile中有这一行:
gem 'debugger' unless ENV["RM_INFO"]

答案 2 :(得分:6)

仅记录来自jetbrains的解决方案: 使用:

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

或者:

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

这确保了Gemfile.lock保持不变,因此具有混合RubyMine和vi / sublime /的组可以愉快地工作,因为不需要RubyMine环境中的gem。

答案 3 :(得分:3)

我遇到了同样的问题,让它花费了我几个小时才能让它运转起来。这是最终得到调试器的东西(这是使用RVM):

  • 退出RubyMine
  • 如果安装了Ruby 1.9.3,请将其卸载:rvm remove 1.9.3
  • 在RVM下安装Ruby 1.9.3:rvm install 1.9.3 --with-gcc=clang - 这会产生错误“不支持的选项' - with-libyaml'”,但我还没有看到任何不良影响
  • 切换到新的红宝石:rvm use 1.9.3
  • 列出并删除所有ruby-debug * gems:gem list | grep debug - gem uninstall <found gems>
  • http://rubyforge.org/frs/?group_id=8883下载linecache19并安装gem,即:gem install linecache19-0.5.13.gem
  • Lauch RubyMine,运行调试器;它将通知缺少调试宝石(即ruby-debug-ide);让RubyMine安装那些。

那是调试器开始工作的时候。另请参阅此RubyMine支持讨论:http://devnet.jetbrains.com/message/5443846#5443846

答案 4 :(得分:0)

今天终于有了一个巨大的kludge黑客。我认为这样做的步骤是

  1. sudo chmod -R 777 ~/.rvm

  2. 让RubyMine做它的事

  3. 除了rake之外,我还确保卸载了我拥有的每一颗宝石。我认为reby-debug-ideruby-debug-base19xlinecache19ruby_core_sourcearchive-tar-minitarcolumnize是重要的。我还卸载了rvm并重新安装了clang。但我会先尝试做chmod的事情。我尝试改为766,但RubyMine不喜欢它。如此巨大的kludge黑客它。我现在收到很多关于Insecure world的警告,但至少调试器正在运行。非常确定下一版本的RubyMine不会使用旧版ruby-debug-base19x,而是使用https://github.com/ruby-debug上最近编辑过的宝石。所以希望有人能在杰出的JetBrains上修复它。顺便说一下,我也尝试用sudo mine运行RubyMine,但这也没办法。

答案 5 :(得分:0)

我在调试器方面遇到了一些问题。 我安装了Rails并将配置选项中的路径设置为rails安装中的ruby.exe,一切都运行良好。