I have a file export.sh which has this content:
export JAVA_HOME="/opt/hadoop/jdk1.7.0_51"
export PATH=$JAVA_HOME/bin:$PATH
I have another shell script (setup.sh) in which I am sourcing export.sh:
source /vagrant/export.sh
setup.sh is called during provisioning:
master.vm.provision :shell, path: "scripts/setup.sh"
But when the machine boots and I try (for example):
which java
it shows blank...
How can I include the newly added path exports in Vagrant?
Add the following line to your setup.sh file:
echo "source /vagrant/scripts/export.sh" >> /home/vagrant/.bashrc
This will ensure that the exports are loaded each time you ssh into the machine, which is what you want to do.
This assumes that your setup.sh is located in the /vagrant/scripts directory on your virtual machine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With