title: gem install rails ERROR: While executing gem ... (Errno::EACCES)
body: <p>I somehow messed my $PATH up. (changed it) and my ruby and rails gems weren't working. What I did in efforts to fix this was to reinstall RVM. Now my ruby works fine in the Terminal. 
  On running <code>gem install rails</code>I get greeted with this: </p>
  
  <p><code>Permission denied - /Users/emKaro/.rvm/gems/ruby-2.0.0-p247/gems/atomic-1.1.13/test/test_atomic.rb
  </code></p>
  
  <p>When I try to install rails through <code>sudo gem install rails</code>, I get this error: </p>
  
  <blockquote>
    <p>ERROR:  While executing gem ... (Errno::EACCES)</p>
  </blockquote>
  
  <p>I have XCode installed with Command-Line tools installed as well. Even went ahead to install GCC but get the very same error when I try to install rails.</p>
  
  <p>This is the full error message</p>
  
  <pre><code>ERROR:  While executing gem ... (Errno::EACCES)
      Permission denied - /Users/emKaro/.rvm/gems/ruby-2.0.0-p247/gems/atomic-1.1.13/test/test_atomic.rb
  emmanuels-imac:~ siaW$ sudo gem install rails
  Password:
  Building native extensions.  This could take a while...
  ERROR:  Error installing rails:
      ERROR: Failed to build gem native extension.
  
      /Users/emKaro/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb
  *** extconf.rb failed ***
  Could not create Makefile due to some reason, probably lack of necessary
  libraries and/or headers.  Check the mkmf.log file for more details.  You may
  need configuration options.
  
  Provided configuration options:
      --with-opt-dir
      --without-opt-dir
      --with-opt-include
      --without-opt-include=${opt-dir}/include
      --with-opt-lib
      --without-opt-lib=${opt-dir}/lib
      --with-make-prog
      --without-make-prog
      --srcdir=.
      --curdir
      --ruby=/Users/emKaro/.rvm/rubies/ruby-2.0.0-p247/bin/ruby
      --with-atomic_reference-dir
      --without-atomic_reference-dir
      --with-atomic_reference-include
      --without-atomic_reference-include=${atomic_reference-dir}/include
      --with-atomic_reference-lib
      --without-atomic_reference-lib=${atomic_reference-dir}/
  /Users/emKaro/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:434:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
  You have to install development tools first.
      from /Users/emKaro/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:519:in `try_link0'
      from /Users/emKaro/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:817:in `try_run'
      from extconf.rb:24:in `&lt;main&gt;'
  
  
  Gem files will remain installed in /Users/emKaro/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/atomic-1.1.13 for inspection.
  Results logged to /Users/emKaro/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/atomic-1.1.13/ext/gem_make.out
  </code></pre>
  
  <p>I am the admin of my computer and running Mac OS 10.8.3. I'd appreciate some help with the rails install.</p>
  
  <p>EDIT:
  Thanks @Christoph
  The only code that helped was to actually remove the RVM folder with
  <code>sudo rm -rf ~/.rvm/</code>
  I tried only to uninstal and it didn't work. So removing the folder and then reinstalling RVM does the job.</p>