fix: add special case for bundler executable
Resolves #8115.
Bundler explicitly provides both bundle and bundler executables. Therefore, it should be possible to resolve both via Gem.bin_path. Special handling is required because bundler lives outside of the current bundle, but previous handling only accounted for the bundle executable. Here we add support for bundler.
What was the end-user or developer problem that led to this PR?
See #8115: the bundler executable cannot be found without special handling.
What is your fix for the problem, implemented in this PR?
Add the same special handling as used for the bundle executable.
Make sure the following tasks are checked
- [x] Describe the problem / feature
- [ ] Write tests for features and bug fixes
- [x] Write code to solve the problem
- [x] Make sure you follow the current code style and write meaningful commit messages without tags
Thanks for opening a pull request and helping make RubyGems and Bundler better! Someone from the RubyGems team will take a look at your pull request shortly and leave any feedback. Please make sure that your pull request has tests for any changes or added functionality.
We use GitHub Actions to test and make sure your change works functionally and uses acceptable conventions, you can review the current progress of GitHub Actions in the PR status window below.
If you have any questions or concerns that you wish to ask, feel free to leave a comment in this PR or join our #rubygems or #bundler channel on Slack.
For more information about contributing to the RubyGems project feel free to review our CONTRIBUTING guide
Hei! Thanks for this fix, it makes sense! It'd be nice to add a spec that loading bundler like this in a bundle exec context succeeds. I'd also like to experiment with removing this monkeypatch completely. I have some ideas for it, give me some days to experiment, and we can proceed with this fix if I don't succeed. But the test would be good to cover either approach.
I believe that either another shortcut for bundler executable should be added, or a clear error message that acknowledges that bundler is special. It seems preferable that bundler also be handled successfully.
bundler was added just to report warning on mistake of using bundler instead of bundle. You should everytime use bundle. @deivid-rodriguez should we change it and make bundler 1:1 with bundle?
bundler was added just to report warning on mistake of using bundler instead of bundle. You should everytime use bundle.
Can you share where it was added? I don't know the story of bundler vs bundle.
@deivid-rodriguez https://github.com/rubygems/rubygems/commit/a809e1c17a62cb222c4070a88550ef4102c43366
I see. It seems the warning was then lost at https://github.com/rubygems/bundler/commit/527e62da9412c9c7039cca7f794539a89f4084d8. It seems an oversight since the commit message does not mention anything about that.
I think we could restore the warning, but fixing this would also be good.
My idea worked fine, so we can fix this issue and at the same time improve Bundler integration with RubyGems by removing this monkeypatch altogether! I also wrote a spec reproducing this problem. Closing in favor of #8165. Thanks @NoRePercussions and @simi!
Nice @deivid-rodriguez.