42

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

51

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.

Sign up to request clarification or add additional context in comments.

8 Comments

@AndrewMarshall: I'll add it to the answer.
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: Please post this as a new question and leave me the link.
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: 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.
|

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.