title: "Don't run bundler as root" - what is the exact difference made by using root?
body: <p>If you run ruby bundler from the command line while logged in as root, you get the following warning:</p>
  
  <blockquote>
    <p>Don't run Bundler as root. Bundler can ask for sudo if it is needed,
    and installing your bundle as root will break this application for all
    non-root users on this machine.</p>
  </blockquote>
  
  <p>What is this exact difference that running bundler as root makes to the gems it installs? </p>
  
  <p>Is it to do with the permissions of the actual files that it installs for each gem? Will Ruby try to access the gem files as a non-root user (and if so, what user / group would Ruby use and how would I find out)?</p>
  
  <p>What would be the symptoms of an application that is broken due to bundler being used as root?</p>
  
  <hr>
  
  <p>My specific reason for asking is because I'm trying to use bundler on a very basic Centos VPS where I have no need to set up any non-root users. I'm <a href="https://stackoverflow.com/questions/25438186/what-could-cause-one-gem-in-a-gemset-to-be-unavailable-while-all-the-others-are">having other problems with gems installed via bundler</a> (<code>Error: file to import not found or unreadable: gemname</code> despite the gem in question being present in <code>gem list</code>), and I'm wondering if installing the gems via bundler as root might have made the files unreadable to Ruby.</p>
  
  <p>I want to work out if I do need to set up a non-root user account purely for running bundler, and if I do, what groups and privileges this user will need to allow Ruby to run the gems bundler installs.</p>
  
  <p>Or can I just <code>chown</code> or <code>chgrp</code> the gem folders? If so, does it depend on anything to do with how Ruby is installed? (I used RVM and my gems end up in <code>/usr/local/rvm/gems/</code> which is owned by root in group rvm) <a href="https://stackoverflow.com/questions/16376995/bundler-cannot-install-any-gems-without-sudo">This loosely related question's answer implies that unspecified aspects of how Ruby is installed influence bundler's permissions requirements</a>.</p>
  
  <p>Researching the "Don't run bundler as root" message only comes up with <a href="https://stackoverflow.com/questions/25210957/dont-run-bundler-as-root-error">an unanswered question</a> and <a href="http://www.coldplaysucks.com/blogs/news/13799949-dont-run-bundler-as-root" rel="noreferrer">complaints that this warning is apparently "like it saying to go to sleep at 8PM" (link contains NSFW language)</a>.</p>