[英]RubyMine/IDEA ruby debugger cannot load linecache gem in bundler mode
Start debugger within bundler (check the "Run the script in bundle context" option in the run target's bundler tab) in IDEA 13 (and earlier version eg 11) Ruby, I always get 在捆绑器中启动调试器(在运行目标的捆绑器选项卡中选中“在捆绑包上下文中运行脚本”选项)在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
The linecache gem is installed properly linecache gem正确安装
$ gem which linecache
/Users/me/.rvm/gems/ree-1.8.7-2012.02/gems/linecache-0.46/lib/linecache.rb
Putting the linecache in Gemfile does not help at all. 将行缓存放在Gemfile中根本没有用。
But launch debugger for the same run target without bundler (unchecking "Run the script in bundle context") works. 但是为没有bundler的同一个运行目标启动调试器(取消选中“在bundle上下文中运行脚本”)可以工作。 Of course, one would get gem conflict easily with bundler context.
当然,人们可以通过捆绑上下文轻松地获得宝石冲突。
How can this be fixed? 怎么解决这个问题?
I found the solution / work around: just add 我找到了解决方案/解决方法:只需添加
require 'rubygems'
to the first line of ruby-debug-base.rb (making sure adding to the right one used by RM/Idea as there can be multiple versions.) 到ruby-debug-base.rb的第一行(确保添加到RM / Idea使用的右边,因为可以有多个版本。)
but I still don't know why it would just work without the bundler option. 但我仍然不知道为什么没有捆绑选项它会工作。 I feel the opposite should be the case.
我觉得情况恰恰相反。
For a cleaner fix than the one provided by Hacking Bear, that avoids having to hack at third-party Gems: 为了获得比Hacking Bear提供的更清晰的解决方案,这可以避免不得不攻击第三方Gems:
Navigate to: Run > Edit Configurations
导航至:
Run > Edit Configurations
Prefix the Ruby arguments
line with: -r rubygems
使用以下命令作为
Ruby arguments
行的前缀: -r rubygems
From the Ruby man-page: 从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.