hannan
hannan

Reputation: 3

Ubuntu "gem install rails" fails

I'm on ubuntu working with rails here What do I get when I try to install gem? Here it is

$ gem install rails
ERROR:  While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /var/lib/gems/2.1.0 directory.

what should I have to do to get it to work?

Upvotes: 0

Views: 3139

Answers (1)

3353755
3353755

Reputation: 73

Normal user accounts generally don't have the ability (often called permissions or privilege) to write to files in the root (starts with "/") directory.

You need to elevate your privilege to that of a superuser, aka the root user. The most common way is to type

sudo [the command you wanted to run]

So type

sudo gem install rails

The system will ask you for your password and if it's your first time running sudo, it will warn you to be careful. :)

Edit: Listen to iceman's comment about using rvm or rbenv instead. Even though using sudo works for this, that does not mean it is the best option.

Upvotes: 1

Related Questions