Skip to content

Conversation

@hsbt
Copy link
Member

@hsbt hsbt commented Dec 8, 2025

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

#7588 intoroduced #9166 and #9159.

I removed install_as_default option and use installer.install in gem update --system. It makes to install full files to default bundler gem. So, we have two copy of bundler-4.0.0 under the GEM_HOME and site_ruby directories.

# gem update --system 2.7.2
❯ fd . 3.4.7/lib/ruby/gems/3.4.0/gems/bundler-2.7.2/
3.4.7/lib/ruby/gems/3.4.0/gems/bundler-2.7.2/exe/
3.4.7/lib/ruby/gems/3.4.0/gems/bundler-2.7.2/exe/bundle
3.4.7/lib/ruby/gems/3.4.0/gems/bundler-2.7.2/exe/bundler

# gem update --system
❯ fd . 3.4.7/lib/ruby/gems/3.4.0/gems/bundler-4.0.0/
3.4.7/lib/ruby/gems/3.4.0/gems/bundler-4.0.0/CHANGELOG.md
3.4.7/lib/ruby/gems/3.4.0/gems/bundler-4.0.0/LICENSE.md
3.4.7/lib/ruby/gems/3.4.0/gems/bundler-4.0.0/README.md
3.4.7/lib/ruby/gems/3.4.0/gems/bundler-4.0.0/bundler.gemspec
3.4.7/lib/ruby/gems/3.4.0/gems/bundler-4.0.0/exe/
3.4.7/lib/ruby/gems/3.4.0/gems/bundler-4.0.0/exe/bundle
3.4.7/lib/ruby/gems/3.4.0/gems/bundler-4.0.0/exe/bundler
3.4.7/lib/ruby/gems/3.4.0/gems/bundler-4.0.0/lib/
3.4.7/lib/ruby/gems/3.4.0/gems/bundler-4.0.0/lib/bundler/
3.4.7/lib/ruby/gems/3.4.0/gems/bundler-4.0.0/lib/bundler/build_metadata.rb
...

That caused to mix same bundler files.

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

Use installer.extract_bin and installer.generate_bin instead of installer.install.

It makes the following result:

❯ fd . 3.4.7/lib/ruby/gems/3.4.0/gems/bundler-4.0.0/
3.4.7/lib/ruby/gems/3.4.0/gems/bundler-4.0.0/exe/
3.4.7/lib/ruby/gems/3.4.0/gems/bundler-4.0.0/exe/bundle
3.4.7/lib/ruby/gems/3.4.0/gems/bundler-4.0.0/exe/bundler

Closes #9166
Closes #9159

Make sure the following tasks are checked

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes an issue where bundler was being installed twice during gem update --system - once as a full gem installation in GEM_HOME and once as a default gem in site_ruby. The fix changes the installation approach to only extract executable files and generate bin wrappers, rather than performing a full gem installation.

Key Changes

  • Replaced installer.install with installer.extract_bin and installer.generate_bin to install only executables
  • Added test coverage to verify executables are present but library files are not extracted
  • Added s.files to test setup gemspec to properly test file extraction behavior

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
lib/rubygems/commands/setup_command.rb Modified install_default_bundler_gem to use extract_bin and generate_bin instead of full install, ensuring only executables are extracted for default bundler gem
test/rubygems/test_gem_commands_setup_command.rb Added test assertions to verify executables are present and lib files are absent; added s.files to test gemspec setup

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@hsbt hsbt force-pushed the fix-default-bundler-installation branch from 2ad7a90 to a70e573 Compare December 8, 2025 07:02
Copy link
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

@hsbt hsbt merged commit 38f6519 into master Dec 8, 2025
79 checks passed
@hsbt hsbt deleted the fix-default-bundler-installation branch December 8, 2025 23:51
hsbt added a commit that referenced this pull request Dec 9, 2025
Fixed unexpected default bundler installation

(cherry picked from commit 38f6519)
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.

Binstubed rake fails to load bundler/gem_tasks bundle exec: superclass mismatch for class Command (TypeError)

3 participants