I have setup a vagrant box using precise64 (ubuntu 14.04) and installed packages needed for octopress. I can ssh into the vagrant box and generate posts and run preview for my octopress site.
Now I want to create a provision script to automatically run following commands once machine is up.
gem install bundler
rbenv rehash
bundle install
rake install
rake generate
rake preview
so I created a shell script using above commands. But when I try to run vagrant up or vagrant provision it's giving me following error.
==> default: ERROR: While executing gem ... (Gem::FilePermissionError)
==> default: You don't have write permissions into the /opt/vagrant_ruby/lib/ruby/gems/1.8 directory.
==> default: bash: rbenv: command not found
My Vagrantfile's provision configuration is like this. I tried privileged option making true too.
config.vm.provision :shell, :privileged => false, :upload_path => "/home/vagrant/octopress/start.sh", :path => "start.sh"
What am I doing wrong here?
As you can see in above logs, provision script is trying to use gem from /opt/vagrant_ruby/lib/ruby/gems directory. But when I ssh into vagrant box and check the location of gem and rbenv, those packages are located inside users home directory (/home/vagrant). The problem seems to provision script is not using 'vagrant' user's environment variables. But when I check whoami inside the script, I am getting vagrant as output.
Is there any way to run provision script with vagrant user's variable?