The problem I was having is that in the context of the provisioning script,
$HOME refers to the
/root/ folder, rather than
It pays to NOT rely on the
$HOME variable when setting environment variables during provisioning, if you want to use those variables later in the provisioning scripts.
Here is my solution (from
config.vm.provision "shell", inline: <<-SHELL echo -n > /etc/profile.d/gopath.sh echo 'export GOROOT=/usr/lib/go' >> /etc/profile.d/gopath.sh echo 'export GOPATH=/home/ubuntu/go' >> /etc/profile.d/gopath.sh echo 'export PATH=$PATH:$GOROOT/bin:$GOPATH/bin' >> /etc/profile.d/gopath.sh SHELL devbox.vm.provision "shell", path: "scripts/my_provision.sh"
After this, this
GOPATH is picked up correctly by
go get and