The answer is:
Vagrant uses
ssh
to log in to theguest
box as the 'vagrant' user. This adds thesshd_config
secure path. In CentOS 6.4 that's:/sbin:/bin:/usr/sbin:/usr/bin
Then it uses
sudo
to become the 'root' user. The profile get's sourced and in CentOS 6.4 that meanssbin
paths are prepended, while$HOME/bin
is appended.Then
chef-solo
runs and path sanity is enforced. Path sanity appends all paths (if not part of the existing$PATH
) at the end, starting withruby_bindir
andgem_bindir
(which refer to the Chef Omnibus installation). Then, every other sane path is appended if not part of$PATH
already, which is why/usr/local/bin
is at the very end.
As Mark O'Connor mentioned, for gem_package
the gem_binary
option can be used to for a certain gem. For other resources the full path can be specified. For shell_out!
though, if a command is to be executed as a user with a login shell first the environment needs to be emptied (enviroment: { 'PATH' => nil }
and bash -l -c
used to execute the desired command.