I am using Vagrant to deploy a virtual machine with several installed packages using shell provisioning. One of the packages needs an update of path to be used properly which I wasn't able to do.
These are the contents of my Vagrantfile:
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
#config.vm.network "forwarded_port", guest: 8888, host: 8888
config.ssh.forward_agent = true
config.vm.provision "shell", path: "provision.sh"
end
These are the following things I tried:
Create a separate .bashrc and .profile files with the following commands (appended at the end of file) and copy them into home directory:
export PATH="/usr/local/x86_64/bin:$PATH"
Try to write into .profile file:
echo 'export PATH="/usr/local/x86_64/bin:$PATH"' >> .profile
Just try exporting PATH during the provisioning (i.e. as a line of code in the provision.sh):
export PATH="/usr/local/x86_64/bin:$PATH"
After vagrant up
command finishes, this command does enable the change of path following vagrant ssh
.
The problem was resolved with the following added to the provision.sh
file based on this post:
echo PATH $PATH
[ -f ~/.profile ] || touch ~/.profile
[ -f ~/.bash_profile ] || touch ~/.bash_profile
grep 'PATH=/usr/local/x86_64/bin' ~/.profile || echo 'export PATH=/usr/local/x86_64/bin:$PATH' | tee -a ~/.profile
grep 'PATH=/usr/local/x86_64/bin' ~/.bash_profile || echo 'export PATH=/usr/local/x86_64/bin:$PATH' | tee -a ~/.bash_profile
. ~/.profile
. ~/.bash_profile
echo PATH $PATH
This works for the precise 64 box all the commands should be one line.
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