Prefer binstubs over bundle exec#6874
Conversation
0c2e819 to
365a3ff
Compare
365a3ff to
df89052
Compare
|
This is reviewable now. |
There was a problem hiding this comment.
Isn't this file generated by bundler or by the gem? Isn't there a risk that it changes in the future?
bundle exec might not be the most elegant, but for me it has been the most reliable way to execute the gem bin across different developer setups.
There was a problem hiding this comment.
Theoretically all of them could change. However they are only a layer of boilerplate, the same for all (all that require Bundler), and only the last line is important.
The binstubs are generated by Bundler, rather than the individual applications. If it changes, it should change for all of them at the same time and... er... oh, what do you know, I just checked now, it changed recently and we are on an old version 😅 Looks like all that noisy check for the bundle executable was removed at ruby/rubygems#8345 Also reminds me that we are on an old version of Bundler...
As for the possibility of this being less reliable than bundle exec:
- Theoretically, it should work better because it removes a layer of indirection.
- But I understand that things work in mysterious ways so I cannot guarantee it. Just for a data point: have you had bad experiences running
bin/railsor similar?
|
Thanks @pablobm . I think I need to mull over this because I have an initial reaction against it.
That's a good reason.
I think it's a bit confusing though, since most of the things are coming from 3rd-party software. So we're just adding wrappers and adding indirection
Do you mean that autocomplete as in The downsides I see are:
|
|
Re: autocomplete, yes, I'm referring to Re: layers of indirection, my impression is that it's lower with binstubs. For example, looking at I used to be a I must admit that this PR started in my head a bit as a pet peeve, but when I saw what was on the guides, I decided to put it in practice. I do understand the frictions at hand, so no worries if you are not convinced. The one thing that I think we should change definitely at the very least is |
|
For 3, 4 and #6784 (comment) something like this could also work: bx() {
if [ "$1" = "yarn" ] || [ "$1" = "dev" ] || [ "$1" = "setup" ]; then
cmd="$1"
shift
"./bin/$cmd" "$@"
else
bundle exec "$@"
fi
}It would even be one character shorter |
This is a proposal to use binstubs over
bundle exec:setup,yarn,dev.Notes:
bundle binstubs.bin/bundle. It's not present in new Rails apps, and it's not the same one you get withbundle binstubs bundler. As a result it was triggering the error "Yourbin/bundlewas not generated by Bundler, so this binstub cannot run". You can see the responsible check in any Bundler-dependent binstubs like the ones added here.bundle exec bin/yarn installis simplified tobin/yarn install, which was a bit excessive :-)config/initializers/doorkeeper.rb, even though that's still generated in that form by Doorkeeper.