Chris vCB
Chris vCB

Reputation: 1053

Vagrant provisioning command does not add aliases to ~/.profile

I have a fairly vanilla Vagrant setup running trusty64. It's being configured by a single shell file. Among others, it contains an aliasing of python3 to python and pip3 to pip, respectively:

echo "Writing aliases to profile:"
echo "alias python=\"python3\"" >> ~/.profile
echo "alias pip=pip3" >> ~/.profile
. ~/.profile

For some mysterious reason, these lines never make it into ~/.profile. There is no error message, nor any other commotion, it's just that nothing happens. This being 2am, I am fairly sure I'm doing something wrong, I just can't figure out what it is.

Upvotes: 0

Views: 612

Answers (1)

Frederic Henri
Frederic Henri

Reputation: 53703

I am pretty sure you're calling the provisioner with something like

config.vm.provision "shell", path: "bootstrap.sh"

This works well but its executed as root user so all the lines are added for this user only. You want to use the privileged option

privileged (boolean) - Specifies whether to execute the shell script as a privileged user or not (sudo). By default this is "true".

config.vm.provision "shell", path: "bootstrap.sh", privileged: "false"

will execute as your vagrant user and will add lines in to /home/vagrant/.profile file

Upvotes: 3

Related Questions