簡體   English   中英

RubyMine / IDEA ruby​​調試器無法在bundler模​​式下加載linecache gem

[英]RubyMine/IDEA ruby debugger cannot load linecache gem in bundler mode

在捆綁器中啟動調試器(在運行目標的捆綁器選項卡中選中“在捆綁包上下文中運行腳本”選項)在IDEA 13(以及早期版本,例如11)Ruby,我總是得到

/Users/me/.rvm/rubies/ree-1.8.7-2012.02/bin/ruby -e at_exit{sleep(1)};$stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/me/.rvm/gems/ree-1.8.7-2012.02/gems/ruby-debug-ide-0.4.22/bin/rdebug-ide --disable-int-handler --port 58100 --dispatcher-port 58101 -- /Users/me/railproj/script/spec --format specdoc spec/**/any_ruby_spec.rb
/Users/me/.rvm/gems/ree-1.8.7-2012.02/gems/ruby-debug-base-0.10.5.rc9/lib/ruby-debug-base.rb:3:in `require': no such file to load -- linecache (LoadError)
    from /Users/me/.rvm/gems/ree-1.8.7-2012.02/gems/ruby-debug-base-0.10.5.rc9/lib/ruby-debug-base.rb:3
    from /Users/me/Library/Application Support/IntelliJIdea13/ruby/rb/gems/debug_preloader.rb:2:in `require'
    from /Users/me/Library/Application Support/IntelliJIdea13/ruby/rb/gems/debug_preloader.rb:2

linecache gem正確安裝

$ gem which linecache
/Users/me/.rvm/gems/ree-1.8.7-2012.02/gems/linecache-0.46/lib/linecache.rb

將行緩存放在Gemfile中根本沒有用。

但是為沒有bundler的同一個運行目標啟動調試器(取消選中“在bundle上下文中運行腳本”)可以工作。 當然,人們可以通過捆綁上下文輕松地獲得寶石沖突。

怎么解決這個問題?

我找到了解決方案/解決方法:只需添加

require 'rubygems'

到ruby-debug-base.rb的第一行(確保添加到RM / Idea使用的右邊,因為可以有多個版本。)

但我仍然不知道為什么沒有捆綁選項它會工作。 我覺得情況恰恰相反。

為了獲得比Hacking Bear提供的更清晰的解決方案,這可以避免不得不攻擊第三方Gems:

導航至: Run > Edit Configurations

使用以下命令作為Ruby arguments行的前綴: -r rubygems

從Ruby手冊頁:

   -r library
          Causes Ruby to load the library using require.  It is useful when using -n or -p.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM