-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Reproduction repo: https://github.com/schneems/bundler-4.0-fails-with-binstub-bundle-clean
Expected
Installing Bundler 4.0.x and then running bundle install followed by bundle clean should not remove the version of bundler that was used to install gems via bundle install
Actual
When you run the script in Dockerfile it installs bundler 4.0.3, runs bundle install && bundle clean then bundle -v returns Bundler version 2.6.9 which is the default verison for Ruby 3.4.8
Run
$ ./reproduce.sh
# ...
Bundler version 2.6.9
Notes
If you remove the bundle clean or you remove the COPY bin ./bin/ (bundler binstub copy) then it returns the correct result.
The bundle clean is used on Heroku and this binstub comes by standard on Rails applications for a LONG time, however stopped being generated in Rails:
- Stop generating bundler binstub: rails/rails#54687
- Stop generating binstubs for Bundler itself #8345
This will cause a lot of failures for older applications that have a checked in bin/bundle binstub that wish to use Bundler 4.0+
Update 2025-12-26: This behavior is consistent with older versions of Bundler when using Ruby with a default Bundler version. It's a regression from Ruby 2.5 with bundler 2.3.27. I do not know the mechanism that prevents bundler from removing itself with that combination. I also don't know why bundler doesn't remove itself when a binstub is not used. Cross-link heroku/heroku-buildpack-ruby#1690.