I am using Vagrant + VirtualBox to set up a virtual machine for my Rails app. I am working on cleaning up a .sh
provisioning script that is referenced in
I'm surprised the provisioning script exits, as running su vagrant
should in theory hang the script at that point (you're running the command su
which does not normally exit by itself).
The problem is you cannot change the user that is running a shell script "on the fly" by running su
.
Your only option is to use sudo
.
Since you just updated .bashrc
with a new path and other settings, you will want to run "sudo bash"
with the -i
option. This will force bash to simulate an interactive login shell, and therefore read .bashrc
and load the correct path for rbenv
.
So, something like this should hopefully work:
echo "building ruby"
sudo -H -u vagrant bash -i -c 'rbenv install 2.2.1 ...'