astashov / vim-ruby-debugger

Vim plugin for debugging Ruby applications (using ruby-debug-ide gem)
435 stars 36 forks source link

Can't debug because 'builder' gem is loaded #89

Closed avivrosenberg closed 11 years ago

avivrosenberg commented 11 years ago

Using MacVim 7.4, ruby 1.9.3p448, bundler 1.3.5.

The issue: I can't debug my app, because vim-ruby-debugger somehow loads or depends on a newer version of the builder gem than my app needs.

I'm developing a non-rails app which requires the 'activerecord' gem to work with some db. This gem depends on 'activemodel' which in turn depends on builder (~> 3.1.0).

When I debug the app, I can step it until it reaches my require 'bundler/setup' line. When stepping over this line I get the following runtime exception:

Uncaught exception: You have already activated builder 3.2.2, but your Gemfile requires builder 3.1.4. Using bundle exec may solve this.

My Gemfile.lock does indeed specify builder 3.1.4, so thats what my app needs and the app runs fine without the debugger. So I'm assuming one of the debugger gems requires the newer version of builder (3.2.2).

What I've tried:

So it seems i've reached a dead end. I need the 'activerecord' gem, it's a core part of the app. But I can't debug the app when I require it.

Any ideas?

Thanks for your help and for developing this awesome plugin!

BTW, in case you need my ruby_debugger_log, here it is...

Vim plugin, 22:13:40: Executing :Rdebugger...
Vim plugin, 22:13:40: Initializing Server object
Vim plugin, 22:13:40: Stopping, pid is: 15558
Vim plugin, 22:13:40: Killing server with pid 15558
Vim plugin, 22:13:40: Executing command: ruby -e 'Process.kill9,15558)'
Vim plugin, 22:13:40: Killed server with pid: 15558
Vim plugin, 22:13:40: Starting Server, command: "'/Users/aviv/dev/mw-maptools/bin/mwmt' --help"
Vim plugin, 22:13:40: Executing command: rdebug-vim --file /Users/aviv/.dotfiles/vim/bundle/vim-ruby-debugger/tmp/ruby_debugger --output /Users/aviv/.dotfiles/vim/bundle/vim-ruby-debugger/tmp/ruby_debugger_output --socket /var/folders/xm/qrq2333160bc638xcj4xnshw0000gn/T/vqeNFv2/88 --logger_file /Users/aviv/.dotfiles/vim/bundle/vim-ruby-debugger/tmp/ruby_debugger_log --debug_mode 1 --vim_executable mvim --vim_servername VIM --separator ++vim-ruby-debugger-separator++ -- '/Users/aviv/dev/mw-maptools/bin/mwmt' --help
debugger-xml, 22:13:40 : Executing command: mvim --servername VIM -u NONE -U NONE --remote-send "<C-\\><C-N>:call RubyDebugger.establish_connection()<CR>"
Vim plugin, 22:13:40: PID: 15576
Vim plugin, 22:13:40: Waiting for starting debugger...
Vim plugin, 22:13:40: Adding 'break /Users/aviv/dev/mw-maptools/bin/mwmt:7' to queue
Vim plugin, 22:13:40: Adding 'break /Users/aviv/dev/mw-maptools/lib/mw-maptools.rb:4' to queue
Vim plugin, 22:13:40: Adding 'start' to queue
Vim plugin, 22:13:40: Executing queue
Vim plugin, 22:13:40: Sending a message to ruby_debugger.rb: 'break /Users/aviv/mw-maptools/bin/mwmt:7;break /Users/aviv/dev/mw-maptools/lib/mw-maptools.rb:4;start'
Vim plugin, 22:13:40: Debugger is successfully started
debugger-xml, 22:13:40 : Executing command: mvim --servername VIM -u NONE -U NONE --remote-send "<C-\\><C-N>:call RubyDebugger.receive_command()<CR>"
debugger-xml, 22:13:40 : Executing command: mvim --servername VIM -u NONE -U NONE --remote-send "<C-\\><C-N>:call RubyDebugger.receive_command()<CR>"
Vim plugin, 22:13:40: Received command: <breakpoint file="/Users/aviv/dev/mw-maptools/bin/mwmt" line="7" threadId="1"/>++vim-ruby-debugger-separator++<frames><frame no="0" file="/Users/aviv/dev/mw-maptools/bin/mwmt" line="7" current="true"/></frames>++vim-ruby-debugger-separator++<variables></variables>
Vim plugin, 22:13:40: Jumped to breakpoint /Users/aviv/dev/mw-maptools/bin/mwmt:7
Vim plugin, 22:13:40: Initializing local variables
Vim plugin, 22:13:40: Received command: <breakpoint file="/Users/aviv/dev/mw-maptools/bin/mwmt" line="7" threadId="1"/>++vim-ruby-debugger-separator++<frames><frame no="0" file="/Users/aviv/dev/mw-maptools/bin/mwmt" line="7" current="true"/></frames>++vim-ruby-debugger-separator++<variables></variables>
Vim plugin, 22:13:40: Jumped to breakpoint /Users/aviv/dev/mw-maptools/bin/mwmt:7
Vim plugin, 22:13:40: Initializing local variables
Vim plugin, 22:13:42: Adding 'cont' to queue
Vim plugin, 22:13:42: Continue
Vim plugin, 22:13:42: Executing queue
Vim plugin, 22:13:42: Sending a message to ruby_debugger.rb: 'cont'
debugger-xml, 22:13:42 : Executing command: mvim --servername VIM -u NONE -U NONE --remote-send "<C-\\><C-N>:call RubyDebugger.receive_command()<CR>"
Vim plugin, 22:13:42: Received command: <breakpoint file="/Users/aviv/dev/mw-maptools/lib/mw-maptools.rb" line="4" threadId="1"/>++vim-ruby-debugger-separator++<frames><frame no="0" file="/Users/aviv/dev/mw-maptools/bin/mwmt" line="4" current="true"/><frame no="1" file="/Users/aviv/dev/mw-maptools/bin/mwmt" line="7" current="false"/></frames>++vim-ruby-debugger-separator++<variables></variables>
Vim plugin, 22:13:42: Jumped to breakpoint /Users/aviv/dev/mw-maptools/lib/mw-maptools.rb:4
Vim plugin, 22:13:42: Initializing local variables
Vim plugin, 22:13:47: Adding 'cont' to queue
Vim plugin, 22:13:47: Continue
Vim plugin, 22:13:47: Executing queue
Vim plugin, 22:13:47: Sending a message to ruby_debugger.rb: 'cont'
astashov commented 11 years ago

Hmm, that's weird. debugger-xml, which is used by vim-ruby-debugger, only requires builder >= 2.0.0 (https://github.com/astashov/debugger-xml/blob/master/debugger-xml.gemspec#L22)

Can you show me your Gemfile.lock?

avivrosenberg commented 11 years ago

Yes, here it is. Thanks for your help.

GEM
  remote: https://rubygems.org/
  specs:
    activemodel (4.0.0)
      activesupport (= 4.0.0)
      builder (~> 3.1.0)
    activerecord (4.0.0)
      activemodel (= 4.0.0)
      activerecord-deprecated_finders (~> 1.0.2)
      activesupport (= 4.0.0)
      arel (~> 4.0.0)
    activerecord-deprecated_finders (1.0.3)
    activerecord-import (0.4.1)
      activerecord (>= 3.0)
    activerecord-postgis-adapter (0.6.5)
      rgeo-activerecord (~> 0.5.0)
    activesupport (4.0.0)
      i18n (~> 0.6, >= 0.6.4)
      minitest (~> 4.2)
      multi_json (~> 1.3)
      thread_safe (~> 0.1)
      tzinfo (~> 0.3.37)
    arel (4.0.0)
    atomic (1.1.14)
    bindata (1.6.0)
    builder (3.1.4)
    colorize (0.6.0)
    i18n (0.6.5)
    minitest (4.7.5)
    multi_json (1.8.1)
    pg (0.17.0)
    rgeo (0.3.20)
    rgeo-activerecord (0.5.0)
      activerecord (>= 3.0.3)
      arel (>= 2.0.6)
      rgeo (>= 0.3.20)
    ruby-progressbar (1.2.0)
    shoulda (3.5.0)
      shoulda-context (~> 1.0, >= 1.0.1)
      shoulda-matchers (>= 1.4.1, < 3.0)
    shoulda-context (1.1.5)
    shoulda-matchers (2.4.0)
      activesupport (>= 3.0.0)
    thread_safe (0.1.3)
      atomic
    trollop (2.0)
    tzinfo (0.3.38)

PLATFORMS
  ruby

DEPENDENCIES
  activerecord
  activerecord-import
  activerecord-postgis-adapter
  bindata
  colorize
  pg
  rgeo
  ruby-progressbar
  shoulda
  trollop
astashov commented 11 years ago

I don't see debugger-xml there at all. Can you try to add it to your Gemfile, and try again?

avivrosenberg commented 11 years ago

Ok, I tried that. Removed Gemfile.lock and ran bundle again. I still get the same error (same versions and everything) when reaching the require 'bundler/setup' line.

Here is the new Gemfile.lock. As you said, debugger-xml does requires builder >= 2.0.0.

GEM
  remote: https://rubygems.org/
  specs:
    activemodel (4.0.0)
      activesupport (= 4.0.0)
      builder (~> 3.1.0)
    activerecord (4.0.0)
      activemodel (= 4.0.0)
      activerecord-deprecated_finders (~> 1.0.2)
      activesupport (= 4.0.0)
      arel (~> 4.0.0)
    activerecord-deprecated_finders (1.0.3)
    activerecord-import (0.4.1)
      activerecord (>= 3.0)
    activerecord-postgis-adapter (0.6.5)
      rgeo-activerecord (~> 0.5.0)
    activesupport (4.0.0)
      i18n (~> 0.6, >= 0.6.4)
      minitest (~> 4.2)
      multi_json (~> 1.3)
      thread_safe (~> 0.1)
      tzinfo (~> 0.3.37)
    arel (4.0.0)
    atomic (1.1.14)
    bindata (1.6.0)
    builder (3.1.4)
    colorize (0.6.0)
    columnize (0.3.6)
    debugger (1.6.2)
      columnize (>= 0.3.1)
      debugger-linecache (~> 1.2.0)
      debugger-ruby_core_source (~> 1.2.3)
    debugger-linecache (1.2.0)
    debugger-ruby_core_source (1.2.3)
    debugger-xml (0.1.8)
      builder (>= 2.0.0)
      debugger (>= 1.6.2)
    i18n (0.6.5)
    minitest (4.7.5)
    multi_json (1.8.1)
    pg (0.17.0)
    rgeo (0.3.20)
    rgeo-activerecord (0.5.0)
      activerecord (>= 3.0.3)
      arel (>= 2.0.6)
      rgeo (>= 0.3.20)
    ruby-progressbar (1.2.0)
    shoulda (3.5.0)
      shoulda-context (~> 1.0, >= 1.0.1)
      shoulda-matchers (>= 1.4.1, < 3.0)
    shoulda-context (1.1.5)
    shoulda-matchers (2.4.0)
      activesupport (>= 3.0.0)
    thread_safe (0.1.3)
      atomic
    trollop (2.0)
    tzinfo (0.3.38)

PLATFORMS
  ruby

DEPENDENCIES
  activerecord
  activerecord-import
  activerecord-postgis-adapter
  bindata
  colorize
  debugger-xml
  pg
  rgeo
  ruby-progressbar
  shoulda
  trollop

I also tried adding builder itself as a dependency in the Gemfile. If I add gem 'builder', '3.2.2' for example and run bundle update builder it gives me an error that the dependency for 'activerecord' can't be met.

avivrosenberg commented 11 years ago

Some extra info: I'm using RVM with two gemsets

I think I might be using RVM/bundler wrong. If I try to remove builder 3.2.2 from my global gemset, it says that debugger-xml depends on it. So maybe removing debugger-xml & builder from the global gemset will do the trick (i'll check that later, and update).

But does it make sense to add debug-only dependencies to my Gemfile? Whats the usual convention?

avivrosenberg commented 11 years ago

I removed all debugger-related gems from my global gemset, including builder. Then I added 'debugger-xml' to my app's Gemfile. Now it works. I guess installing 'debugger-xml' into the global gemset caused the installation of 'builder 3.2.2' (the newest version thats >= 2.0.0 which is what debugger-xml needs). Since the global gemset is always included, the gemset for my app had two versions of builder in it... When running the app through the debugger, the newer builder was loaded first, and when reaching the bundler require line, bundler tried to load the older version thats specified in the Gemfile.lock.

So it's not a problem with the debugger actually... sorry :) Thanks again.

astashov commented 11 years ago

I guess installing 'debugger-xml' into the global gemset caused the installation of 'builder 3.2.2' (the newest version thats >= 2.0.0 which is what debugger-xml needs).

Yeah, right.

But does it make sense to add debug-only dependencies to my Gemfile? Whats the usual convention?

Well, this is development dependency. I usually create a group in my Gemfile for them, like:

group :development do
  gem "debugger-xml"
end

And then just exclude it when deploying to production.