0

I have a shell script in /etc/profile.d that adds some directories to my $PATH, but vagrant doesn't see when running a privileged provisioning script. This uses sudo and sudo does not see this modified $PATH.

Is there a way to get vagrant to see this path?

EDIT: Added some clarifying words. I'm just looking for how to modify the $PATH in a privileged provisioning script.

1 Answer 1

2

/etc/profile (and /etc/profile.d) are sourced only when you establish an interactive session. Vagrant's SSH connection is non-interactive and these files are not used.

You need to put your PATH in a file that gets sourced on non-interactive login. If you use bash, then in /etc/.bash.bashrc or .bashrc for vagrant user.

4
  • Provisioning scripts are run as sudo, though, so they won't get that PATH variable either.
    – wsaxton
    Aug 10, 2016 at 6:05
  • By default, provisioning scripts are run via "sudo". Putting a modification in ~/.bash_profile for vagrant user will not effect the PATH used within the provisioning script.
    – wsaxton
    Aug 10, 2016 at 6:30
  • My vagrant provisioning script runs a command called "r10k" which calls another command called "puppet". r10k assumes that puppet is in my path. It isn't. Therefore I'm trying to get it in there!
    – wsaxton
    Aug 10, 2016 at 6:55
  • I updated the answer I the meantime, for non-interactive bash /etc/.bash.bashrc is sourced.
    – techraf
    Aug 10, 2016 at 7:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .