简体   繁体   English

RubyMine / IDEA ruby​​调试器无法在bundler模​​式下加载linecache gem

[英]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.

相关问题 安装debugger-linecache(1.1.1)时发生错误,Bundler无法继续 - An error occurred while installing debugger-linecache (1.1.1), and Bundler cannot continue 带有@global gem的Ruby / RVM - bundle运行失败,带有`require':无法加载这样的文件 - bundler(LoadError) - Ruby/RVM with @global gem - bundle run fails with `require': cannot load such file — bundler (LoadError) Ruby on Rails RubyMine调试器问题 - Ruby on Rails RubyMine debugger issues Rubymine调试模式测试框架意外退出-无法加载此类文件 - Rubymine debug mode test framework quit unexpectedly - cannot load such file 无法在 Rails 控制台中加载使用 bundler 安装的 gem - Cannot load gem installed using bundler in rails console Bundler - 无法加载2个不同版本的完全相同的gem? - Bundler - cannot load 2 different versions of the exact same gem? Ruby:“gem install bundler”没有安装bundler - Ruby: “gem install bundler” not installing bundler 无法在ruby193上安装linecache19 gem - Unable to install linecache19 gem on ruby193 Ruby Gem(EventMachine)不会使用Bundler GEM安装 - Ruby Gem (EventMachine) Will Not Install Using the Bundler GEM Ruby on Rails:错误“require”:无法加载此类文件——bundler/setup (LoadError) - Ruby on Rails: Error `require': cannot load such file -- bundler/setup (LoadError)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM