rubygems icon indicating copy to clipboard operation
rubygems copied to clipboard

fix: add special case for bundler executable

Open NoRePercussions opened this issue 1 year ago • 7 comments

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

NoRePercussions avatar Oct 08 '24 15:10 NoRePercussions

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

welcome[bot] avatar Oct 08 '24 15:10 welcome[bot]

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.

deivid-rodriguez avatar Oct 08 '24 19:10 deivid-rodriguez

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?

simi avatar Oct 09 '24 06:10 simi

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 avatar Oct 09 '24 06:10 deivid-rodriguez

@deivid-rodriguez https://github.com/rubygems/rubygems/commit/a809e1c17a62cb222c4070a88550ef4102c43366

simi avatar Oct 09 '24 06:10 simi

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.

deivid-rodriguez avatar Oct 09 '24 06:10 deivid-rodriguez

I think we could restore the warning, but fixing this would also be good.

deivid-rodriguez avatar Oct 09 '24 06:10 deivid-rodriguez

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!

deivid-rodriguez avatar Oct 21 '24 19:10 deivid-rodriguez

Nice @deivid-rodriguez.

simi avatar Oct 21 '24 19:10 simi