Skip to content

Bundler 4.0.4 leaks incorrect source into gems #9258

@ngan

Description

@ngan

Describe the problem as clearly as you can

Bundler 4.0.4 includes a change to how the source is determined for a gem:

I think this change introduced a bug. Here's a copy-paste of what I'm seeing in terminal with some gem names and URLs redacted:

$ bundle update kt-paperclip

Fetching gem metadata from https://gemstash.my-private-gemstash.com/private/.....
Fetching gem metadata from https://gems.karafka.io/.
Fetching gem metadata from https://enterprise.contribsys.com/..
Fetching gem metadata from https://gems.graphql.pro/..
Fetching gem metadata from https://rubygems.org/........
Resolving dependencies...
Could not find compatible versions

Because my_custom_gem >= 2.3.0 depends on aws-sdk-elasticache ~> 1
  and aws-sdk-elasticache ~> 1 could not be found in rubygems repository https://gemstash.my-private-gemstash.com/private/,
  gusto-my_custom_gem >= 2.3.0 cannot be used.
So, because Gemfile depends on my_custom_gem = 2.4.7,
  version solving has failed.

I'm trying to bump the kt-paperclip gem and it's saying the aws-sdk-elasticache gem couldn't be found in my private gemstash--which makes sense. But, it shouldn't be looking for aws-sdk-elasticache there in the first place. My my_custom_gem is in my private gemstash. My guess is that the source for my gem is bleeding into aws-sdk-elasticache somehow.

I removed my_custom_gem from my gemfile and another, similar, problem surfaced where it was looking for a public gem inside a pathed source.

One piece of information that might be relevant is that my Gemfile does not declare a direct dependency on aws-sdk-elasticache. It is a dependency of my custom gem. I think the bundler rule is look in the same source as my_custom_gem and if it's not there, fallback to the global source: https://bundler.io/v4.0/man/gemfile.5.html#SOURCE-PRIORITY

Let me know if y'all need more information for reducibility, happy to provide.

👉 Downgrading to bundler 4.0.3 fixes the issue.

Post steps to reproduce the problem

Coming soon...
Just putting this up in case something obvious sticks out from the change.

Which command did you run?

bundle update

What were you expecting to happen?

I expect my gem to be upgraded.

What happened instead?

It wasn't upgrade. See top.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions