Prevent passing version to bin/bundle
#2765
Merged
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.
Motivation
Closes #2731
If the user has their local
bin
directory as part of thePATH
and abin/bundle
binstub exists, we accidentally invoke the binstub rather than invokingbundle exec
.This is problematic because the binstub doesn't accept the same arguments as the bundle executable. Namely, we can't pass the version using
_2.5.12_
to ensure that the locked Bundler version is used and no restarts happen.I'd argue that overriding the
bundle
executable with something that doesn't support the same arguments is not great as it prevents any tools from invoking Bundler directly, which is what they may legitimately want to do (this is the Ruby LSP's case).However, it appears that this affects a considerable number of users, so let's put in a fix to prevent this error from happening.
Implementation
If there's a
bin/bundle
and any parts of the path are pointing to the localbin
directory, then we favour using the binstub with no version.Otherwise, we continue doing the same as before. I'm hesitant to expand this to always use the binstub if present since people could have modified their binstubs and that may lead to other errors.
Automated Tests
I added two new tests.