Skip to content

rdbg + Bundler -> numerous gem version conflicts #676

Closed

Description

@xeger

Your environment

  • ruby -v: ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [arm64-darwin21]
  • rdbg -v: rdbg 1.4.0

Describe the bug
My goal is to debug RSpec test cases in a large project that uses Bundler. (Integrating with VS Code, but that is not relevant to this bug report.) The command that I invoke is:

rdbg --command --open --stop-at-load --sock-path=<foo> -- bundle exec rspec <bar>/spec/zzz_im_spec.rb

# tried this variant too
bundle exec rdbg --command --open --stop-at-load --sock-path=<foo> -- bundle exec rspec <bar>/spec/zzz_im_spec.rb

However, my bundle includes conflicting versions of numerous gems that ruby/debug requires by itself: io-console, irb, json, reline and timeout. It's not clear to me whether all of these are default gems -- I don't think so, but maybe I'm wrong and the default gems have exploded in Ruby 3! Regardless, I end up with conflicts because Bundler tries to activate the version in my Gemfile, but debug has already activated a different version. It raises:

You have already activated io-console 0.5.11, but your Gemfile requires io-console 0.5.6. Since io-console is a default gem, you can either remove your dependency on it or try updating to a newer version of bundler that supports io-console as a default gem. (Gem::LoadError)

This is very mysterious considering that this happens even when debug is explicitly installed in the bundle and rdbg is invoked via bundle exec.

To Reproduce
Add any of the gems mentioned above to the Gemfile; io-console 0.5.6 is a good test case with Ruby 3.1.1 and rdbg 1.4.0. Then just invoke rdbg and ask it to run bundle exec on any script file that activates the bundle. (I can create a self-contained reproduction as a gist, if you are interested.)

Expected behavior

  • There should be some way to use rdbg with Bundler, because both of them are default gems
  • I have a workaround (align Gemfile perfectly with default gems) but wish I didn't need to do this

Additional context
I realize this isnt' necessarily a bug in debug; I'm hoping for guidance. Happy to work on a fix, if this is indeed a bug.

Activity

  1. ko1 commented on Jul 5, 2022

    @ko1
    Collaborator

    Sorry my environment says ruby 3.1.1 has io-console 0.5.11.
    Could you make another example?

    [master]$ ruby -v
    ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [x86_64-linux]
    
    ko1@WSL2 ~/src/rb/ruby-debug/app/gem
    [master]$ gem list io-console
    
    *** LOCAL GEMS ***
    
    io-console (default: 0.5.11)
    

    BTW I'm happy if you write step-by-step repro steps.

  2. xeger commented on Jul 5, 2022

    @xeger
    ContributorAuthor

    Thank you for your quick reply. Here is a repro for you:
    https://gist.github.com/xeger/e8cc98437d9c8351c8ed8dc4faa19591

    The README has instructions on how to repro.

    Now that I understand the root cause, the workaround doesn't seem so bad. In fact, it seems fairly sane: if I upgrade to a newer Ruby, I should be willing to delete Gemfile.lock and re-resolve all dependencies, including default gems.

    Still: I wanted to show you the issue and give you an easy repro. I'm not sure that debug can do anything about this, other than avoid requiring any default gems.

  3. ko1 commented on Jul 6, 2022

    @ko1
    Collaborator

    Thank you, I can reproduce it very easy.

    As you said it seems difficult to solve it if we use rdbg (rdbg command
    I tried to add gem 'debug' in Gemfile and run bundle install, debug 0.2.1 (not debug.gem) is installed!

    Thank you again and I close this ticket. If anyone has better solution, please reopen it.

  4. ko1 commented on Jul 6, 2022

    @ko1
    Collaborator

    Note that bundle update also fixes the issue.

  5. xeger commented on Jul 6, 2022

    @xeger
    ContributorAuthor

    Oh; and, you have found an excellent solution!

    # specifically ask for "new" debug gem (not legacy 0.2.1 unrelated gem)
    gem 'debug', '1.5.0'
    

    With the "new debug" in the Gemfile, Bundler warns about version conflicts (i.e. irb must be newer) and bundle exec rdbg works as expected.

    🎉

  6. ko1 commented on Jul 6, 2022

    @ko1
    Collaborator

    Wow, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions