gem install rails ERROR: While executing gem ... (Errno::EACCES)

ruby-on-rails, rubygems

Solution

Like Dave pointed out up there, there should be no need to sudo any Gem installation. You could try to reset the permissions on your RVM directory:

sudo chown -R emKaro: ~/.rvm/

and try your Gem instllation again. If that doesn't work out, you should consider removing your RVM installation and start over:

sudo rm -rf ~/.rvm/   # remove your RVM directory

There should really be no need for using sudo in any of this.

Problem

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 `gem install rails`I get greeted with this: `Permission denied - /Users/emKaro/.rvm/gems/ruby-2.0.0-p247/gems/atomic-1.1.13/test/test_atomic.rb ` When I try to install rails through `sudo gem install rails`, I get this error: ERROR: While executing gem ... (Errno::EACCES) 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. This is the full error message ``` 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 `<main>' 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 ``` I am the admin of my computer and running Mac OS 10.8.3. I'd appreciate some help with the rails install. EDIT: Thanks @Christoph The only code that helped was to actually remove the RVM folder with `sudo rm -rf ~/.rvm/` I tried only to uninstal and it didn't work. So removing the folder and then reinstalling RVM does the job.

Original source