Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use correct Bundler version when updating gems #29

Merged
merged 2 commits into from
Aug 1, 2024

Conversation

mattbrictson
Copy link
Owner

Before, update-interactive would update gems using whatever bundle binary was in the PATH. On Rails projects, there is often a binstub for Bundler located at bin/bundle. If this bin directory is in the PATH, then the binstub is executed instead of Bundler being executed directly.

Using the binstub is problematic, because the binstub locks the version of Bundler to the BUNDLED WITH value of the lock file. The binstub makes an exception for this behavior when running bin/bundle update, so that the latest version of Bundler is used when updating gems. However, this auto-detection only works when the binstub is invoked directly in the shell. Since update-interactive wraps the invocation of the update command, the binstub falls back to locking the version of Bundler at whatever is in the lock file.

As a result, update-interactive would not update the lockfile with the version of Bundler that the user intended.

Fix by using Gem.bin_path to get the correct Bundler executable, rather than using a binstub that might be in the user's PATH.

Before, `update-interactive` would update gems using whatever `bundle`
binary was in the PATH. On Rails projects, there is often a binstub for
Bundler located at `bin/bundle`. If this `bin` directory is in the PATH,
then the binstub is executed instead of Bundler being executed directly.

Using the binstub is problematic, because the binstub locks the version
of Bundler to the `BUNDLED WITH` value of the lock file. The binstub
makes an exception for this behavior when running `bin/bundle update`,
so that the latest version of Bundler is used when updating gems.
However, this auto-detection only works when the binstub is invoked
directly in the shell. Since `update-interactive` wraps the invocation
of the update command, the binstub falls back to locking the version of
Bundler at whatever is in the lock file.

As a result, `update-interactive` would not update the lockfile with the
version of Bundler that the user intended.

Fix by using `Gem.bin_path` to get the correct Bundler executable,
rather than using a binstub that might be in the user's PATH.
@mattbrictson mattbrictson added the 🐛 Bug Fix Fixes a bug label Aug 1, 2024
@mattbrictson mattbrictson merged commit 40dd0a3 into main Aug 1, 2024
8 checks passed
@mattbrictson mattbrictson deleted the use-correct-bundler-ver branch August 1, 2024 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Fix Fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant