mattbrictson / bundle_update_interactive

A stylish interactive mode for Bundler, inspired by `yarn upgrade-interactive`
MIT License
137 stars 3 forks source link

Use correct Bundler version when updating gems #29

Closed mattbrictson closed 1 month ago

mattbrictson commented 1 month ago

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.