title: ruby gems under rvm on Ubuntu (failing to) install in the wrong location
body: <p>I'm running Ubuntu 10.04 and originally installed ruby 1.9.1 (from source).  I've just decided to try out ruby 1.9.2 and rails 3, and it seemed like a good time to use rvm to deal with the multiple ruby installs and gemsets.</p>
  
  <p>rvm installed and seems to be working,  I installed ruby 1.9.2 in rvm and made that my default ruby.  However, every time I try to install a gem under ruby 1.9.2 I see this error.</p>
  
  <pre><code>mark@Steve-Austins-Penguin:~$ gem install haml  
  ERROR:  While executing gem ... (Errno::EACCES)  
  Permission denied - /home/mark/.gem/specs
  </code></pre>
  
  <p><code>gem environment</code> returns:</p>
  
  <pre><code>RubyGems Environment:  
  - RUBYGEMS VERSION: 1.3.7  
  - RUBY VERSION: 1.9.2 (2010-08-18 patchlevel 0) [x86_64-linux]  
  - INSTALLATION DIRECTORY: /home/mark/.rvm/gems/ruby-1.9.2-p0  
  - RUBY EXECUTABLE: /home/mark/.rvm/rubies/ruby-1.9.2-p0/bin/ruby  
  - EXECUTABLE DIRECTORY: /home/mark/.rvm/gems/ruby-1.9.2-p0/bin  
  - RUBYGEMS PLATFORMS:  
  - ruby  
  - x86_64-linux  
  - GEM PATHS:  
   - /home/mark/.rvm/gems/ruby-1.9.2-p0  
   - /home/mark/.rvm/gems/ruby-1.9.2-p0@global  
  &lt;snip&gt;
  </code></pre>
  
  <p>But if the correct installation, ruby and gem paths are showing here why is ruby trying to install gems to <code>/home/mark/.gem</code>?  All the variables and paths shown by <code>env</code> look right, and I can't find a <code>.gemrc</code> file anywhere on my system that might contain conflicting path settings.</p>
  
  <p>So I guess my question is what might be causing rubygems to attempt to install to <code>/home/mark/.gems</code> instead of the correct paths set by rvm?</p>
  
  <hr>
  
  <p>In response to the question below:</p>
  
  <pre><code>mark@Steve-Austins-Penguin:~$ echo $PATH
  /home/mark/.rvm/gems/ruby-1.9.2-p0/bin:/home/mark/.rvm/gems/ruby-1.9.2-p0@global/bin:/home/mark/.rvm/rubies/ruby-1.9.2-p0/bin:/home/mark/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games  
  mark@Steve-Austins-Penguin:~$ which gem
  /home/mark/.rvm/rubies/ruby-1.9.2-p0/bin/gem
  mark@Steve-Austins-Penguin:~$ rvm list
  
  rvm rubies
  
     ruby-1.8.7-p302 [ x86_64 ]
  =&gt; ruby-1.9.2-p0 [ x86_64 ]
  
  mark@Steve-Austins-Penguin:~$ env
  rvm_gemsets_path=/home/mark/.rvm/gemsets
  MANPATH=:/home/mark/.rvm/man
  rvm_scripts_path=/home/mark/.rvm/scripts
  rvm_bin_path=/home/mark/.rvm/bin
  GEM_HOME=/home/mark/.rvm/gems/ruby-1.9.2-p0
  rvm_patchsets_path=/home/mark/.rvm/patchsets
  SHELL=/bin/bash
  IRBRC=/home/mark/.rvm/rubies/ruby-1.9.2-p0/.irbrc
  rvm_patches_path=/home/mark/.rvm/patches
  MY_RUBY_HOME=/home/mark/.rvm/rubies/ruby-1.9.2-p0
  rvm_selfcontained=1
  USER=mark
  __shell_array_start=0
  rvm_gems_cache_path=/home/mark/.rvm/gems/cache
  rvm_config_path=/home/mark/.rvm/config
  rvm_path=/home/mark/.rvm
  USERNAME=mark
  rvm_gemset_separator=@
  rvm_ruby_args=
  rvm_rubies_path=/home/mark/.rvm/rubies
  PWD=/home/mark
  rvm_hooks_path=/home/mark/.rvm/hooks
  rvm_version=1.0.1
  rvm_src_path=/home/mark/.rvm/src
  HOME=/home/mark
  rvm_gems_path=/home/mark/.rvm/gems
  rvm_ruby_string=ruby-1.9.2-p0
  BUNDLE_PATH=/home/mark/.rvm/gems/ruby-1.9.2-p0
  rvm_tmp_path=/home/mark/.rvm/tmp
  LOGNAME=mark
  GEM_PATH=/home/mark/.rvm/gems/ruby-1.9.2-p0:/home/mark/.rvm/gems/ruby-1.9.2-p0@global
  rvm_action=list
  rvm_log_path=/home/mark/.rvm/log
  rvm_interactive=1
  RUBY_VERSION=ruby-1.9.2-p0
  rvm_archives_path=/home/mark/.rvm/archives
  rvm_repo_path=/home/mark/.rvm/repos
  _=/usr/bin/env
  </code></pre>
  
  <p>Note that I've edited down the response from <code>env</code> slightly - simply to keep the size of this post under control - by removing all the entries relating to X, GNOME and SSH.</p>