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!
btw, some quirk I had to fight some time ago: https://gist.github.com/973177
Currently I'm using Bundler.with_clean_env, but I still have to provide BUNDLE_GEMFILE='"Gemfile" to make it working (when executing bunler commands from within another project that is also using bundler). I was wondering why with clean env this BUNDLE_GEMFILE still is necessary (sorry that it's not completely relevant to above ;)