title: RubyGems installation errors both when using 'sudo' and not using sudo
body: <p>I have a machine that is running Ubuntu Hardy, which provides its own RubyGems package.  Unfortunately that version of RubyGems (1.1.1) is too old to do anything useful with, so I decided to manually update RubyGems to the current version (1.3.6).  That part went smoothly, and if I do <code>gem -v</code>, I get <code>1.3.6</code> which is expected.  The problem is when I try to do: <code>sudo gem install rack</code>, it returns this error:</p>
  
  <pre><code>ERROR:  While executing gem ... (Errno::EACCES)
  Permission denied - /home/username/.gem
  </code></pre>
  
  <p>Usually when I install gems as root, it knows to install it into <code>/usr/lib/ruby/gems</code>, so why is it checking my home directory at all?  Another quirk is when I do <code>gem install rack</code> (not as root), it says:</p>
  
  <pre><code>ERROR:  While executing gem ... (Gem::FilePermissionError)
  You don't have write permissions into the /usr/lib/ruby/gems/1.8 directory.
  </code></pre>
  
  <p>which is where I want it to go.  I've already tried clearing source_caches, trying different versions of RubyGems (1.3.5), forcing installation into <code>/usr/lib</code> with <code>-i</code> to no avail.  Any ideas on why RubyGems is so insistent on checking my <code>/home</code> directory when installing as root?</p>