Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundler fixes #2923

Merged
merged 12 commits into from Jul 16, 2014
Merged

Bundler fixes #2923

merged 12 commits into from Jul 16, 2014

Conversation

Kriechi
Copy link
Contributor

@Kriechi Kriechi commented Jul 2, 2014

This splits the bundler-commands into seperate lines, to allow easier adding, deleting and therefore merging of new PRs.

fixes #1817
fixes #1825
fixes #2779
fixes #2200
fixes #2561
fixes #2076
fixes #1818
fixes #2885

already fixed, but issue still open:
closes #2695

not needed:
closes #2074

spring is added.
pry is added.
sidekiq is added.
ruby is removed.
berks is removed.
foreman is removed.
spin is removed.

If a binstub in ./bin/ exists, it is called instead of bundle exec <gem>.

Added functionality to include additional executables with wrapper: BUNDLED_COMMANDS.

A README.md file is added to document this plugin. Added documentation on how BUNDLED_COMMANDS and UNBUNDLED_COMMANDS works.

@lorin
Copy link

lorin commented Jul 2, 2014

👍

@KevinBongart
Copy link
Contributor

I believe it would still work without the \ (and look cleaner?):

bundled_commands=(
  annotate
  berks
  cap
  capify
  cucumber
  foodcritic
  guard
  irb
  jekyll
  kitchen
  knife
  middleman
  nanoc
  puma
  rackup
  rainbows
  rake
  rspec
  ruby
  shotgun
  sidekiq
  spec
  spork
  strainer
  tailor
  taps
  thin
  thor
  unicorn
  unicorn_rails
)

@Kriechi
Copy link
Contributor Author

Kriechi commented Jul 2, 2014

thanks @KevinBongart - you are right.
I've updated everything accordingly.

@KevinBongart
Copy link
Contributor

Awesome, thanks

@mcornella
Copy link
Member

Hi @Kriechi, thanks for taking the initiative with the bundler plugin.

When I was triaging issues I saw a lot related to the bundler plugin, so I saved them in case I made a super-PR like the one you're doing now. Since this PR intends to fix the bundler plugin, it makes sense to try to fix these issues and test these PRs. So here you go:

Delete ruby from bundled_commands

This one is mentioned several times and it seems, the most prominent being in #1587 which is related to postmodern/chruby#80. They suggest using binstubs, as is done in #2885. I don't know if that could be a possible solution.

#1587: bundler plugin should probably not re-alias ruby

Several modifications to bundled_commands

All these seem rather silly, we have already an UNBUNDLED_COMMANDS variable to unalias those commands that clash with people's workflow.
Why not add a BUNDLED_COMMANDS too -- with some predefined commands that seem general and harmless enough for everybody, like rake or rspec -- and let people use that instead of submitting yet another PR.
Or better yet, we can have a custom precmd function that aliases those commands that finds as a binstub. I don't know if that made sense 😅

Initialization mods

Quick background: #2243 introduced a bug that is solved by #2278; this last one makes sure it loads after rbenv (I don't know if it works).

#2243: bundle plugin throwing error when bundle is not in path while initializing
#2278: Bundle version check only needed bundler installation check, other commands to be bound

Bundler completion

Other

#2732: Adds bundler bump completion


And that's all I found. Disclaimer: I don't use bundler (nor ruby that much) to have any authority over any of this, but if I can help with the zsh part I'll gladly do it. I can't test any of it though (unless someone points me to a primer on bundler and I find the time to set it up).

@Kriechi
Copy link
Contributor Author

Kriechi commented Jul 4, 2014

I think #2278 no longer applies, because the underlying if-then-else is already refactored.
I removed ruby and berks from the bundled_commands list.
Already fixed but still open: #2695
I have merged #1818 into this PR.
I have merged #2885 into this PR and removed the double bundle-exec call.
Bundler binstubs are already with bundler.

@Kriechi
Copy link
Contributor Author

Kriechi commented Jul 4, 2014

Why not add a BUNDLED_COMMANDS too -- with some predefined commands that seem general and harmless enough for everybody, like rake or rspec -- and let people use that instead of submitting yet another PR.

Wouldn't this only work if bundler-plugin is loaded last, so that each other plugin can register a binary, and then the bundler-plugin creates all wrappers?

I'm not familiar with precmd - maybe you could show me a quick gist on how this could help us here?

@mcornella
Copy link
Member

Wouldn't this only work if bundler-plugin is loaded last, so that each other plugin can register a binary, and then the bundler-plugin creates all wrappers?

I'm not sure I understand. It would work the same way the UNBUNDLED_COMMANDS array works now; see #2655 (comment) for reference.


About the precmd thing; zsh allows to execute functions before the prompt is written (precmd) or before the command is executed (preexec). In this case, we would make a custom function that looks if we're in a directory with binstubs, like so:

  • If we enter a project with binstubs, alias them: alias COMMAND=bin/COMMAND; then track them by adding them in a dedicated array: aliased_binstubs+=(COMMAND)
  • When we exit a project with binstubs, unalias them.

I don't think if it makes sense, nor how does it affect other ruby workflow commands like rbenv and chruby and such. I see that this approach is too complicated to put it in an easy-merge PR, so I could make a separate PR and discuss it there. What do you think?

@Kriechi
Copy link
Contributor Author

Kriechi commented Jul 4, 2014

UNBUNDLED_COMMANDS - yeah - now I get it. Yes, I will add a similiar thing for additional gems with BUNDLED_COMMANDS.

I will add a README.md to document those two configuration options for the users.

I think using a preexec hook (or something like that) is very invasive.
Wouldn't it be easier to just add ./bin/ to PATH? but this implies a lot of security issues.
So I would leave this out of this PR. Maybe later on we can work something out.

@Kriechi
Copy link
Contributor Author

Kriechi commented Jul 7, 2014

@mcornella @lorin @KevinBongart I have added additional things (README.md, BUNDLED_COMMANDS functionality)
Could you please take a look?

@mcornella I think I have covered all easy issues you mentioned in your first comment. Please let me know if there is anything major left.

@KevinBongart
Copy link
Contributor

@Kriechi Nice work! Thanks for taking care of that :)

I've added three tiny comments since I couldn't update the README file directly

@Kriechi
Copy link
Contributor Author

Kriechi commented Jul 7, 2014

@KevinBongart thanks. I've fixed it.

@mcornella
Copy link
Member

Awesome job @Kriechi, I added a little remark to the README.

I have also updated my comment to check those issues you tackled (:

Only remain:

Already dealt with:

Thank you very much! 😄

@sabarish-soft
Copy link
Contributor

@mcornella i have closed the PR as it is not required, Thanks for letting me know :)

@Kriechi
Copy link
Contributor Author

Kriechi commented Jul 10, 2014

I would not pull #2074 - IMHO is this gem fine without bundle exec.
Also, it seems to be a bit unmaintained or not popular enough to deserve the tag common gem.

So now everything mentioned should either be merged, fixed or otherwise dealt with.
I'm happy to pull in other (new) Bundler-related PRs (mention it and ping me).

IMHO this PR is ready to merge.

@mcornella
Copy link
Member

Yeah that's what I thought too, thanks for confirming it. Maybe we can close it? The author doesn't seem to respond anymore.

Anyway, this PR is ready to merge too in my opinion 👍

@KevinBongart
Copy link
Contributor

👍

@robbyrussell
Copy link
Member

@Kriechi Can you rebase once more for me?

@Kriechi
Copy link
Contributor Author

Kriechi commented Jul 15, 2014

done.

robbyrussell added a commit that referenced this pull request Jul 16, 2014
@robbyrussell robbyrussell merged commit 15c5d59 into ohmyzsh:master Jul 16, 2014
@robbyrussell
Copy link
Member

Thanks!

@Kriechi Kriechi deleted the bundler-fixes branch July 16, 2014 07:55
@fabn
Copy link

fabn commented Jan 27, 2022

This is linked into readme, but I don't get why rails has been removed from bundled commands, what issue are caused to have it in bundled_commands?

@mcornella
Copy link
Member

This is linked into readme, but I don't get why rails has been removed from bundled commands, what issue are caused to have it in bundled_commands?

From https://stackoverflow.com/a/23846736:

The one notorious exception to this rule is the rails command. The reason being that the first thing the rails command does is load up bundler and check which version of the command to execute. So you'd really just be slowing yourself down to involve bundler in the first place when running the rails command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
9 participants