Skip to content

Fix Bundler crashing when it tries to install plugin:#9335

Merged
hsbt merged 1 commit into
ruby:masterfrom
Shopify:ec-bundler-plugin-fix
Feb 18, 2026
Merged

Fix Bundler crashing when it tries to install plugin:#9335
hsbt merged 1 commit into
ruby:masterfrom
Shopify:ec-bundler-plugin-fix

Conversation

@Edouard-chin
Copy link
Copy Markdown
Member

@Edouard-chin Edouard-chin commented Feb 16, 2026

What was the end-user or developer problem that led to this PR?

Bundler crashes when a Gemfile contains a plugin and you try to run bundle install while setting the BUNDLE_WITHOUT=default value.

What is your fix for the problem, implemented in this PR?

Context

Setting the BUNDLE_WITHOUT=default is something that some deployment tooling does like shipit. The intent being to only install gems that are required to deploy the app (for instance ones that are inside a group :deploy block).

Solution

Bundler assume that all plugins inside the Gemfile will get installed, but don't take in consideration that a BUNDLE_WITHOUT may have affected this.

So before registering a plugin, make sure it's actually in the specs object (meaning it was installed on disk).

Make sure the following tasks are checked

plugin_should_be_installed("foo")
end

it "respects bundler groups" do
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without the fix, this test just crashes

Image

Copy link
Copy Markdown
Member

@kou kou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Comment thread bundler/lib/bundler/plugin.rb Outdated
next if index.installed?(name)

spec = specs[name]
next if spec.nil? || index.installed?(name)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be better that we have a comment when spec is nil.

- ### Problem

  Bundler crashes when a Gemfile contains a plugin and you
  try to run `bundle install` while setting the BUNDLE_WITHOUT=default
  value.

  ### Context

  Setting the BUNDLE_WITHOUT=default is something that some deployment
  tooling does like [shipit](https://github.com/Shopify/shipit-engine/blob/a24b9d8b1b777e22f05311705be7938a4823eee6/app/models/shipit/deploy_spec/bundler_discovery.rb#L6)
  The intent being to only install gems that are required to deploy
  the app (for instance ones that are inside a `group :deploy` block).

  ### Solution

  Bundler assume that all plugins inside the Gemfile will get
  installed, but don't take in consideration that a BUNDLE_WITHOUT
  may have affected this.

  So before registering a plugin, make sure it's actually in
  the `specs` object (meaning it was installed on disk).
Copy link
Copy Markdown
Member

@hsbt hsbt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks to catch this 👍

@hsbt hsbt merged commit faa64e2 into ruby:master Feb 18, 2026
92 checks passed
hsbt added a commit that referenced this pull request Feb 24, 2026
Fix Bundler crashing when it tries to install plugin:

(cherry picked from commit faa64e2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants