User does COMMAND (rake, rackup, gist, rails, etc.). What does he mean?
The user almost certainly means to run the binary against system. Success!
Ambiguous. It depends on a few more details.
Ambiguous. The user may be using a system command to bootstrap (e.g. rake bundle).
If we choose bundle exec
, the command will fail because the gems are not available
on the system.
If we choose the system, they may be running a command like rackup
, which should
fail if the necessary gems are not available on the system.
Ambiguous.
Are all of the gems in the Gemfile.lock present on the system? If not, ambiguous. The user may be using a system command to bootstrap.
Is the gem associated with the executable present in the Gemfile.lock, and specified
as a top-level gem? If so, the user almost certainly wants bundle exec
. Success!
Is the gem associated with the executable present in the Gemfile.lock, but not
specified as a top-level gem? If so, ambiguous. We cannot tell whether the user
knows that the gem is a dependency of a gem they included. Example: rdoc is a
dependency of a number of gems. If the user types rdoc
, do they know that?
Is the gem unassociated with any gem in the Gemfile.lock. If so, the user almost
certainly does not want bundle exec
. Success!
There's a lot of magic involved in bundler. All well thought and did for user convenience. But I would still prefer simplicity. For example oh-my-zsh bundler plugin will execute everything through bundle exec when Gemfile is present and all that analysis is very important. But I don't like that approach, because IMHO it will never work nicely, because of shell extensions, aliases, need for whitelist and stuff. I would like bundler to always execute stuff from Gemfile. If user wants to bootstrap, he should not use "bundle exec". Just random 2 cents, thanks for sharing these thoughts.