Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugin directive doesn't honor version constraint #7415

Open
Fryguy opened this issue Jan 23, 2024 · 2 comments
Open

plugin directive doesn't honor version constraint #7415

Fryguy opened this issue Jan 23, 2024 · 2 comments
Labels

Comments

@Fryguy
Copy link
Contributor

Fryguy commented Jan 23, 2024

Describe the problem as clearly as you can

The plugin directive when given a version installs that version, but doesn't use it if an upgrade has occurred. Instead it seems to use what's in the index, but the index is not updated to the requested version.

Did you try upgrading rubygems & bundler?

Yes, this occurs on latest bundler and I also see it happening as far back as 2.4.17 (and probably further, but I didn't continue back)

Post steps to reproduce the problem

Start with this basic Gemfile:

source "https://rubygems.org"
plugin "bundler-commentate", "~> 0.2.0"

Then bundle install. This works as expected.

Next update the version in the Gemfile:

source "https://rubygems.org"
plugin "bundler-commentate", "~> 0.3.0"

Then bundle install. You will notice that 0.3.0 gets installed correctly, however the index does not reflect that update:

$ ls -l .bundle/plugin/gems
total 0
drwxr-xr-x@ 13 jfrey  staff  416 Jan 23 15:34 bundler-commentate-0.2.0
drwxr-xr-x@ 13 jfrey  staff  416 Jan 23 15:34 bundler-commentate-0.3.0
drwxr-xr-x@  6 jfrey  staff  192 Jan 23 15:34 parser-3.3.0.5
drwxr-xr-x@  5 jfrey  staff  160 Jan 23 15:34 unparser-0.6.12

$ cat .bundle/plugin/index
---
commands:
  commentate: "bundler-commentate"
hooks:
load_paths:
  bundler-commentate:
  - "/Users/jfrey/dev/test/bundler_plugin_issue/.bundle/plugin/gems/bundler-commentate-0.2.0/lib"
plugin_paths:
  bundler-commentate: "/Users/jfrey/dev/test/bundler_plugin_issue/.bundle/plugin/gems/bundler-commentate-0.2.0"
sources:

Next, to show that the version being used is incorrect, we can modify the source to display the version on use, so run the following (apologies for this hacky way, but I was having a really hard time finding a plugin that was versioned and also showed the version - we can probably invent one for specs)

$ echo 'puts "Bundler::Commentate::VERSION: #{Bundler::Commentate::VERSION}"' >> .bundle/plugin/gems/bundler-commentate-0.2.0/lib/bundler/commentate/version.rb
$ echo 'puts "Bundler::Commentate::VERSION: #{Bundler::Commentate::VERSION}"' >> .bundle/plugin/gems/bundler-commentate-0.3.0/lib/bundler/commentate/version.rb

Now run bundler commentate --help. You will see that it is using version 0.2.0 even though we've requested 0.3.0.

The seemingly only workaround at this point is to rm -rf .bundle and then redo bundle install.

Which command did you run?

What were you expecting to happen?

What actually happened?

See above.

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

Environment

Bundler       2.5.5
  Platforms   ruby, arm64-darwin-22
Ruby          3.0.6p216 (2023-03-30 revision 23a532679b406cb53c0edfc00c91c32a5ccd335a) [arm64-darwin-22]
  Full Path   /Users/jfrey/.rubies/ruby-3.0.6/bin/ruby
  Config Dir  /Users/jfrey/.rubies/ruby-3.0.6/etc
RubyGems      3.2.33
  Gem Home    /Users/jfrey/.gem/ruby/3.0.6
  Gem Path    /Users/jfrey/.gem/ruby/3.0.6:/Users/jfrey/.rubies/ruby-3.0.6/lib/ruby/gems/3.0.0
  User Home   /Users/jfrey
  User Path   /Users/jfrey/.gem/ruby/3.0.0
  Bin Dir     /Users/jfrey/.gem/ruby/3.0.6/bin
Tools
  Git         2.42.0
  RVM         not installed
  rbenv       not installed
  chruby      0.3.9

Bundler Build Metadata

Built At          2024-01-18
Git SHA           2efa8cec93
Released Version  true

Gemfile

Gemfile

source "https://rubygems.org"
plugin "bundler-commentate", "~> 0.3.0"

Gemfile.lock

GEM
  remote: https://rubygems.org/
  specs:

PLATFORMS
  arm64-darwin-22
  ruby

DEPENDENCIES

BUNDLED WITH
   2.5.5
@Fryguy Fryguy added the Bundler label Jan 23, 2024
@kbrock
Copy link

kbrock commented Jan 23, 2024

This is tricky to debug since a bundle update will blow away any modifications you make in .bundle/plugin/gem directory.

Also, using path for your plugin (and not version) will link the index directly to your source code outside of the .bundle directoy and will not properly show the issue.

Once you follow through @Fryguy comments and agree there probably is an issue here, I think checking that the .bundle/plugin/index is updated is your best quick detect for whether this works or not.

@Fryguy
Copy link
Contributor Author

Fryguy commented Jan 24, 2024

The .bundle/plugin/index not pointing to the correct gem feels like the smoking gun, but I didn't want to make the assumption that just because the index says one thing that something else wasn't going on. So, the "hack" code is there to prove that it's actually executing the wrong plugin as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants