title: Vagrant - Install Ruby Gems
body: <p>When run vagrant provision, instead of install the ruby gems in user environment, install in the root user environment.</p>
  
  <p>Here is my vagrant file:</p>
  
  <pre><code># -*- mode: ruby -*-
  # vi: set ft=ruby :
  
  Vagrant.configure("2") do |config|
  
  config.vm.box = "scotch/box"
  config.vm.network "private_network", ip: "192.168.33.10"
  config.vm.hostname = "scotchbox"
  config.vm.synced_folder ".", "/var/www", :mount_options =&gt; ["dmode=777", "fmode=666"]
  
  # Optional NFS. Make sure to remove other synced_folder line too
  #config.vm.synced_folder ".", "/var/www", :nfs =&gt; { :mount_options =&gt; ["dmode=777","fmode=666"] }
  
  config.vm.provision "shell", path: "provision/install.sh"
  config.vm.provision "shell", path: "provision/install-gems.sh"
  end
  </code></pre>
  
  <p>And the install-gems.sh:</p>
  
  <pre><code>#!/usr/bin/env bash
  
  echo "- install sass ..."  
  gem install sass
  echo "- install sass done"
  
  echo "- install compass ..."
  gem install compass
  echo "- install compass done"
  
  echo "- install bootstrap-sass ..."
  gem install bootstrap-sass
  echo "- install bootstrap-sass done"
  </code></pre>
  
  <p>When i run <code>gem list</code>, the gems not appears, but when i run <code>sudo gem list</code>, they do, which i don't want to.</p>
  
  <p>How can i in vagrant install the gems in not root mode? Try to add the <code>privileged: false</code> in vagant file, but not work because of privileges.</p>
  
  <p>Thanks! </p>