Repository navigation
Load FileUtils before starting Bundler's worker threads - #10020
Merged
Merged
Conversation
Autoloading the vendored FileUtils moved its first use into the gem
download workers whenever rake is already installed. CRuby makes other
threads wait for an autoload in progress, but TruffleRuby shows them the
constant while its file is still loading, so a second worker can call
mkdir_p before fu_list is defined:
NoMethodError: undefined method 'fu_list' for module Bundler::FileUtils
Require it in Worker#create_threads, the one place Bundler starts threads.
worker.rb itself is loaded by definition.rb, so requiring it at the top of
that file would load FileUtils on every `require "bundler/setup"` again.
hsbt
approved these changes
Nov 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was the end-user or developer problem that led to this PR?
Since #10001 autoloads the vendored FileUtils,
bundle installon TruffleRuby can fail intermittently:It failed
bin/rake dev:depsin this job on #10005, which doesn't touch FileUtils. The same job passed on master at e771d2c, so it depends on timing.CRuby makes other threads wait for an autoload in progress. TruffleRuby 34.0.1 shows them the constant while its file is still loading, so a second worker can call
mkdir_p(line 396) beforefu_list(line 2485) exists.ParallelInstallerinstalls rake on the main thread first, which loads FileUtils there, so the first use only lands in the download workers when rake is already installed, as it is in this job.What is your fix for the problem, implemented in this PR?
Require FileUtils at the start of
Worker#create_threads, the only place inlib/bundlerthat starts a thread, so it has finished loading before any worker exists.I chose this over a
requireat the top ofworker.rbbecausedefinition.rbloads that file, which would bring FileUtils back on everyrequire "bundler/setup"and undo #10001. The existing "does not load the vendored FileUtils" spec still passes.Verification
With a
sleepadded to a copy of the vendoredfileutils.rbto stretch the load, staggered jobs through a realBundler::Workeron TruffleRuby 34.0.1 (arm64-darwin):fu_listerror aboveI couldn't reproduce the failure through a full
bundle installlocally, even with the stretched load, so that path rests on this job in CI. JRuby wasn't tested.The new spec fails without the change (
expected: "true",got: "false").Make sure the following tasks are checked
🤖 Generated with Claude Code