Skip to content

Different version of bundler gets executed depending on the executable name, bundle or bundler #7777

@x-yuri

Description

@x-yuri

Describe the problem as clearly as you can

Likely a minor issue, but it can possibly affect other cases. The culprit is here. When one runs bundle update --bundler, then bundler_version returns nil, prioritize! doesn't change the list of matches, matching_specs returns all of them, find_spec_for_exe chooses the first (newest) one, which is being activated.

With bundler update --bundler bundle_update_bundler_version returns nil, bundler_version, prioritize!, and matching_specs returns the version from the lockfile, which is being activated.

I ran into it a while ago while trying to update bundler from 1.x to 2.x, when it still outputted the Using lines, which is likely how I noticed it, but I either considered it unimportant or didn't have time.

Did you try upgrading rubygems & bundler?

I didn't try updating Rubygems because the line is still unchanged.

Post steps to reproduce the problem

$ docker run --rm -it alpine:3.20 sh -euxc '
    apk add ruby
    gem install bundler -v 2.5.13
    gem install bundler -v 2.2.2
    sed -i "/def run/aputs Bundler::VERSION" /usr/lib/ruby/gems/3.3.0/gems/bundler-2.2.2/lib/bundler/cli/update.rb
    sed -i "/def run/aputs Bundler::VERSION" /usr/lib/ruby/gems/3.3.0/gems/bundler-2.5.13/lib/bundler/cli/update.rb
    echo "source \"https://rubygems.org\"" > Gemfile
    bundle _2.2.2_
    bundle update --bundler
    rm Gemfile.lock
    bundle _2.2.2_
    bundler update --bundler
'
...
+ bundle _2.2.2_
...
+ bundle update --bundler
2.5.13
Fetching gem metadata from https://rubygems.org/.
The Gemfile specifies no dependencies
Resolving dependencies...
Bundle updated!

+ rm Gemfile.lock

+ bundle _2.2.2_
...
+ bundler update --bundler
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
2.2.2
The Gemfile specifies no dependencies
Bundle updated!

Which command did you run?

bundle update --bundler and bundler update --bundler

What were you expecting to happen?

Identical behavior.

What actually happened?

Different versions of bundler were executed.

If not included with the output of your command, run bundle env and paste the output below

Environment

Bundler       2.5.13
  Platforms   ruby, x86_64-linux-musl
Ruby          3.3.1p55 (2024-04-23 revision c56cd86388092faec079981f779f140717020d58) [x86_64-linux-musl]
  Full Path   /usr/bin/ruby
  Config Dir  /etc
RubyGems      3.5.9
  Gem Home    /usr/lib/ruby/gems/3.3.0
  Gem Path    /root/.local/share/gem/ruby/3.3.0:/usr/lib/ruby/gems/3.3.0
  User Home   /root
  User Path   /root/.local/share/gem/ruby/3.3.0
  Bin Dir     /usr/bin
Tools         
  Git         not installed
  RVM         not installed
  rbenv       not installed
  chruby      not installed

Bundler Build Metadata

Built At          2024-06-14
Git SHA           5525a3d9b0
Released Version  true

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions