title: how to install gems without sudo
body: <p>On all my gem installs I have to do sudo ? So </p>
  
  <blockquote>
    <p>sudo gem install rails</p>
  </blockquote>
  
  <p>will work, while only </p>
  
  <blockquote>
    <p>gem install rails</p>
  </blockquote>
  
  <p>will not work. How do I remedy it ?</p>
  
  <p>I have rvm installed - </p>
  
  <pre><code>murtaza@murtaza-dev:~$ which rvm
  /home/murtaza/.rvm/bin/rvm
  
  murtaza@murtaza-dev:~$ which gem
  /home/murtaza/.rvm/rubies/ruby-1.9.3-p194/bin/gem
  </code></pre>
  
  <p>However I am also getting this warning when I do any operations with gem - </p>
  
  <pre><code>murtaza@murtaza-dev:~$ gem
  /home/murtaza/.rvm/rubies/ruby-1.9.3-p194/bin/gem:4: warning: Insecure world writable dir /opt in PATH, mode 040777
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>I have reinstalled rvm using <code>curl -L get.rvm.io | bash -s stable --auto</code> (without sudo). </p>
  
  <p>However still when I try installing gem it gives me the following error - </p>
  
  <pre><code>murtaza@murtaza-dev:~$ gem install rails
  /home/murtaza/.rvm/rubies/ruby-1.9.3-p194/bin/gem:4: warning: Insecure world writable dir /opt in PATH, mode 040777
  ERROR:  While executing gem ... (Errno::EACCES)
      Permission denied - /home/murtaza/.gem/specs
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>I did chown on the whole thing but still getting the error - </p>
  
  <pre><code>murtaza@murtaza-dev:~$ sudo chown murtaza.murtaza -R ~/.rvm/*
  
  
   murtaza@murtaza-dev:~$ gem install rails
      /home/murtaza/.rvm/rubies/ruby-1.9.3-p194/bin/gem:4: warning: Insecure world writable dir /opt in PATH, mode 040777
      ERROR:  While executing gem ... (Errno::EACCES)
          Permission denied - /home/murtaza/.gem/specs
  </code></pre>