41

I'm trying to install Rails using Gem and did the following from the terminal:

sudo apt-get install ruby-full build-essential
sudo apt-get install rubygems
export PATH=/var/lib/gems/1.8/bin:$PATH
gem install rails

Then I get the following message:

ERROR: While executing gem ... (Errno:EACCES) Permission denied - /var/lib/gems

I've followed the instruction from Ubuntu Help Guide & I'm using Oracle VM VirtualBox to run Ubuntu under Windows 7 and have RubyGems v1.8.15.

0

1 Answer 1

50

You need to prefix the gem command with sudo because /var/lib/gems is owned by root. You could also take a look at RVM which allows really easy installation and management of gems and Ruby versions. Best part, it's all in your home dir!

EDIT: per @AndrewMarshall's comment bellow, rbenv is an alternative to RVM.

8
  • @AndrewMarshall: I'll add it to the answer.
    – Linuxios
    Jul 16, 2012 at 0:13
  • Hi I am getting this error while using RVM funkdified@vizio ~/rails_projects/goodsounds.org $ rvm current ruby-1.9.3-p392@goodsounds funkdified@vizio ~/rails_projects/goodsounds.org $ gem install bundler Fetching: bundler-1.3.2.gem (100%) ERROR: While executing gem ... (Errno::EACCES) Permission denied - /var/lib/gems
    – Abram
    Mar 9, 2013 at 2:55
  • @Abram: Please post this as a new question and leave me the link.
    – Linuxios
    Mar 9, 2013 at 4:57
  • I've set gems's permission too 777 at /var/lib/. Why should it be a problem now? I am still getting error. I tried chowning it by the current user pi and reverting permission back to 755 then it worked but then I got an error at /usr/local/bin where I changed the permission to 777 it worked.
    – amar
    Oct 14, 2013 at 18:49
  • 1
    @amar: Because gem needs to be able to access root owned directories. But don't change the permissions of root owned anything. It's a really bad idea. Just use sudo.
    – Linuxios
    Oct 14, 2013 at 19:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.