I am running the following script from a Vagrantfile and everything is working fine. In the end, I see the output go1.10 linux/amd64
as expected.
But, when I run vagrant ssh
I get The program 'go' is currently not installed
.
What is the difference between vagrant provision that was able to see go
and vagrant ssh
that was not able to see go
?
config.vm.box = "ubuntu/xenial64"
config.vm.provision "shell" do |s|
s.inline = "
sudo apt-get update
export GOPATH=$HOME/work
sudo curl -O https://storage.googleapis.com/golang/go1.10.linux-amd64.tar.gz
sudo tar -xvf go1.10.linux-amd64.tar.gz
sudo mv go /usr/local
sudo echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.profile
export PATH=$PATH:/usr/local/go/bin
go version" # this row is working fine on the script but not after ssh
end
In order to make your changes to $PATH
available to all users, you have to change it in the global profile, not the user's. Change the line
sudo echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.profile
to
sudo echo 'export PATH=$PATH:/usr/local/go/bin' >> /etc/profile