title: Vagrant/VirtualBox VM provisioning: rbenv installs successfully but subsequent uses in script fail
body: <p>I am using Vagrant + VirtualBox to set up a virtual machine for my Rails app. I am working on cleaning up a <code>.sh</code> provisioning script that is referenced in <code>Vagrantfile</code> like so:</p>
  
  <pre><code>config.vm.provision "shell", path: "script/provision-script.sh" 
  </code></pre>
  
  <p>The provision script does a number of things, but towards the end it is supposed to install rbenv Ruby versioning and then use rbenv to install Ruby 2.2.1. That part of the provision script looks like this:</p>
  
  <pre><code>echo "setting up rbenv"
  # execute the remaining commands as vagrant user, instead of root
  sudo -H -u vagrant bash -c "git clone https://github.com/sstephenson/rbenv.git ~vagrant/.rbenv"
  sudo -H -u vagrant bash -c "git clone https://github.com/sstephenson/ruby-build.git ~vagrant/.rbenv/plugins/ruby-build"
  sudo -H -u vagrant bash -c "git clone https://github.com/sstephenson/rbenv-gem-rehash.git ~vagrant/.rbenv/plugins/rbenv-gem-rehash"
  echo "setting up rbenv environment in bash"
  echo 'export PATH="$HOME/.rbenv/bin:$PATH"' &gt;&gt; ~vagrant/.bashrc
  echo 'eval "$(rbenv init -)"' &gt;&gt; ~vagrant/.bashrc
  
  # start new vagrant shell so rbenv will work
  echo "building ruby"
  su vagrant
  rbenv install 2.2.1 &amp;&amp; rbenv global 2.2.1 &amp;&amp; rbenv rehash &amp;&amp; cd /path/to/my/app &amp;&amp; gem install bundler rake &amp;&amp; rbenv rehash &amp;&amp; bundle &amp;&amp; rbenv rehash
  </code></pre>
  
  <p>Everything up to the <code>rbenv install...</code> part works correctly. Installing ruby fails with the following error:</p>
  
  <pre><code>==&gt; default: setting up rbenv
  ==&gt; default: Cloning into '/home/vagrant/.rbenv'...
  ==&gt; default: Cloning into '/home/vagrant/.rbenv/plugins/ruby-build'...
  ==&gt; default: Cloning into '/home/vagrant/.rbenv/plugins/rbenv-gem-rehash'...
  ==&gt; default: setting up rbenv environment in bash
  ==&gt; default: building ruby
  ==&gt; default: /tmp/vagrant-shell: line 73: rbenv: command not found
  </code></pre>
  
  <p>The script then finishes. I can open the vm with <code>vagrant ssh</code> and then successfully run <code>rbenv install 2.2.1</code>, so I'm guessing that during provisioning a new vagrant shell is not actually being started. I was under the impression that this should happen with <code>su vagrant</code> right before <code>rbenv install 2.2.1</code>. </p>
  
  <p>What can I do to make sure that a new shell is initialized during this provisioning and that the <code>rbenv</code> command will work?</p>