Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have installed Ubuntu 12.04 on VirtualBox.

I installed rvm, ruby and rails following this tutorial.

But when I restart, I am getting this error:

The program 'rails' is currently not installed.  You can install it by typing:
sudo apt-get install rails

And after that, when I again try gem install rails I am getting this error:

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

And there is no gems folder under /var/lib/.

Can anyone help me to fix this?

share|improve this question
add comment

2 Answers 2

up vote 5 down vote accepted

gem install rails needs to be run as root since /var/lib/gems should be 0644 or something. Therefore, use:

sudo gem install rails
share|improve this answer
add comment

There is a couple ways to install rails, one is straight from apt and another from ruby gems.

apt-get install ruby-rails-3.2

This isn't the best way to install rails, it's better to have ruby gems handle rails for you. First make sure that ruby and ruby gems are up to date

$ ruby -v && gem -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
1.8.23

Run

$ apt-get update && apt-get upgrade

To get the latest versions.
NOTE: You got his error

PERMISSION DENIED

Run the exact command with sudo prepended to the command so

sudo gem install rails

Should be the correct way to install rails.

Be careful when using the sudo command, make sure you know what you are doing. As the saying goes "With great power comes great responsibility" and sudo is no exception.

share|improve this answer
2  
Using sudo every time a command gives PERMISSION DENIED isn't a good idea. Some commands do this for a reason if something shouldn;t be tampered with, others that access files (with mangled permissions) in a personal folder might mangle them even more. –  hexafraction Jan 27 '13 at 22:24
    
I agree and that's why I included a note about being careful with sudo. –  Dillon Gilmore Feb 1 '13 at 6:59
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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