Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set path in vagrant machine

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?

like image 626
user2230605 Avatar asked Dec 01 '25 03:12

user2230605


1 Answers

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.

like image 60
Hans Kristian Avatar answered Dec 05 '25 22:12

Hans Kristian