Skip to content

Conversation

@deivid-rodriguez
Copy link
Contributor

@deivid-rodriguez deivid-rodriguez commented Dec 20, 2024

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

Bundler generated binstubs are sometimes too strict, and error out directly, preventing Bundler auto-install and auto-switch mechanism from triggering.

We have two mechanisms that are almost identical for activating the proper version of Bundler, with only one difference:

  • One lives in RubyGems. This puts the most appropiate Bundler version first in the list, but will fallback to other versions if not present. This mechanism is backed up by code in Bundler to automatically install the locked version of Bundler, and restart with it if the best version was not activated initially.
  • The other one lives in Bundler binstubs. This actually sets a ~> x.y constraint on the version of Bundler, so it could end up in errors.

In particular, when vendor/bundle is configured, and a minor version of Bundler is running that that does match the locked version of Bundler, Bundler binstubs will bail out with an error. If they were not in place, Bundler internal mechanism would automatically restart with the locked version of Bundler itself present in vendor/bundle and everything would just work.

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

Stop generating binstubs for Bundler itself, since they are no longer necessary, given that the same (more relaxed) mechanism is present in all RubyGems version that we support.

Make sure the following tasks are checked

@deivid-rodriguez deivid-rodriguez force-pushed the deivid-rodriguez/stop-generating-bundler-binstubs branch from f69a01c to 3db9c19 Compare December 20, 2024 13:31
@deivid-rodriguez
Copy link
Contributor Author

I plan to add code suggesting to explain what happened and suggesting to remove bin/bundle if bundle binstubs <gem> --force is run and the previous binstub was loading bin/bundle.

@simi
Copy link
Contributor

simi commented Jan 11, 2025

I plan to add code suggesting to explain what happened and suggesting to remove bin/bundle if bundle binstubs <gem> --force is run and the previous binstub was loading bin/bundle.

Would you like to add this into current PR or in separate one?

@deivid-rodriguez
Copy link
Contributor Author

I was planning to add it to this PR.

@deivid-rodriguez
Copy link
Contributor Author

deivid-rodriguez commented Jan 28, 2025

I briefly looked into adding those messages I had suggested, but I decided it's fine as is, so will merge.

@deivid-rodriguez deivid-rodriguez force-pushed the deivid-rodriguez/stop-generating-bundler-binstubs branch 2 times, most recently from 293a2c0 to 088c919 Compare January 28, 2025 17:14
@deivid-rodriguez deivid-rodriguez force-pushed the deivid-rodriguez/stop-generating-bundler-binstubs branch from 088c919 to 8d596c0 Compare January 29, 2025 13:03
@deivid-rodriguez deivid-rodriguez merged commit 574ff35 into master Jan 29, 2025
91 checks passed
@deivid-rodriguez deivid-rodriguez deleted the deivid-rodriguez/stop-generating-bundler-binstubs branch January 29, 2025 14:40
@y-yagi
Copy link
Contributor

y-yagi commented Mar 2, 2025

Rails generates binstub when generating a new application, and, uses it in some cases.
https://github.com/rails/rails/blob/bf80199d4890441465ed12623b09f2324aaf234e/railties/lib/rails/generators/app_base.rb#L768

For example, authentication genertor uses bin/bundle command when generating files.
https://github.com/rails/rails/blob/bf80199d4890441465ed12623b09f2324aaf234e/railties/lib/rails/generators/rails/authentication/authentication_generator.rb#L47
https://github.com/rails/rails/blob/bf80199d4890441465ed12623b09f2324aaf234e/railties/lib/rails/generators/actions.rb#L470

So I assume this change may be breaking change. How about showing a deprecation message before stoping generation?

Ref: rails/rails#54563

Edouard-chin added a commit to Edouard-chin/rails that referenced this pull request Mar 4, 2025
- Fix rails#54563
- ### Context

  In a future version of Bundler, running `bundle binstub bundler`
  will no longer generate a `bin/bundle` binstub.
  The reason for this change upstream is well explained in
  ruby/rubygems#8345.

  ### Problem

  When the change in Bundler is cut into a release, generating
  new rails application will throw a Bundler warning, and
  the AuthenticationGenerator which makes use of `bin/bundle` will
  stop working.

  ### Solution

  Stop generating a bundler binstub and modify the generator
  to use the same bundler command as the rest of the codebase.
Edouard-chin added a commit to Edouard-chin/rails that referenced this pull request Mar 4, 2025
- Fix rails#54563
- ### Context

  In a future version of Bundler, running `bundle binstub bundler`
  will no longer generate a `bin/bundle` binstub.
  The reason for this change upstream is well explained in
  ruby/rubygems#8345.

  ### Problem

  When the change in Bundler is cut into a release, generating
  new rails application will throw a Bundler warning, and
  the AuthenticationGenerator which makes use of `bin/bundle` will
  stop working.

  ### Solution

  Stop generating a bundler binstub and modify the generator
  to use the same bundler command as the rest of the codebase.
Edouard-chin added a commit to Edouard-chin/rails that referenced this pull request Mar 4, 2025
- Fix rails#54563
- ### Context

  In a future version of Bundler, running `bundle binstub bundler`
  will no longer generate a `bin/bundle` binstub.
  The reason for this change upstream is well explained in
  ruby/rubygems#8345.

  ### Problem

  When the change in Bundler is cut into a release, generating
  new rails application will throw a Bundler warning, and
  the AuthenticationGenerator which makes use of `bin/bundle` will
  stop working.

  ### Solution

  Stop generating a bundler binstub and modify the generator
  to use the same bundler command as the rest of the codebase.
Edouard-chin added a commit to Edouard-chin/rails that referenced this pull request Mar 4, 2025
- Fix rails#54563
- ### Context

  In a future version of Bundler, running `bundle binstub bundler`
  will no longer generate a `bin/bundle` binstub.
  The reason for this change upstream is well explained in
  ruby/rubygems#8345.

  ### Problem

  When the change in Bundler is cut into a release, generating
  new rails application will throw a Bundler warning, and
  the AuthenticationGenerator which makes use of `bin/bundle` will
  stop working.

  ### Solution

  Stop generating a bundler binstub and modify the generator
  to use the same bundler command as the rest of the codebase.
@deivid-rodriguez
Copy link
Contributor Author

I did assume this PR could break some stuff, that's why I plan to release it with next's year release, not on a patch version.

Maybe worth adding some deprecation note now in a patch level release, though.

Edouard-chin added a commit to Edouard-chin/rails that referenced this pull request Mar 5, 2025
- Fix rails#54563
- ### Context

  In a future version of Bundler, running `bundle binstub bundler`
  will no longer generate a `bin/bundle` binstub.
  The reason for this change upstream is well explained in
  ruby/rubygems#8345.

  ### Problem

  When the change in Bundler is cut into a release, generating
  new rails application will throw a Bundler warning, and
  the AuthenticationGenerator which makes use of `bin/bundle` will
  stop working.

  ### Solution

  Stop generating a bundler binstub and modify the generator
  to use the same bundler command as the rest of the codebase.
Edouard-chin added a commit to Edouard-chin/rails that referenced this pull request Mar 5, 2025
- Fix rails#54563
- ### Context

  In a future version of Bundler, running `bundle binstub bundler`
  will no longer generate a `bin/bundle` binstub.
  The reason for this change upstream is well explained in
  ruby/rubygems#8345.

  ### Problem

  When the change in Bundler is cut into a release, generating
  new rails application will throw a Bundler warning, and
  the AuthenticationGenerator which makes use of `bin/bundle` will
  stop working.

  ### Solution

  Stop generating a bundler binstub and modify the generator
  to use the same bundler command as the rest of the codebase.
@y-yagi
Copy link
Contributor

y-yagi commented Mar 5, 2025

I understood the plan. Thanks for your explanation!

flavorjones added a commit to rails/tailwindcss-rails that referenced this pull request Aug 20, 2025
which was failing because the bundler binstub has been removed in
modern bundler, see ruby/rubygems#8345
flavorjones added a commit to rails/tailwindcss-rails that referenced this pull request Aug 20, 2025
which was failing because the bundler binstub has been removed in
modern bundler, see ruby/rubygems#8345
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.

4 participants