satya
satya

Reputation: 3560

Getting Errorno-EACCES error while installing Rails on ubuntu

I successfully installed ruby on my Ubuntu server by using the following command.

1-sudo apt-get install python-software-properties
2-sudo apt-add-repository ppa:brightbox/ruby-ng
3-sudo apt-get update
4-sudo apt-get install ruby2.1

But when i tried to install Rails version 4.2.0 using the below command.

gem install rails --version=4.2.0

i got the following error.

Error:

Error:While executing gem (Errorno-EACCES)
permission denied @ dir_s_mkdir - /var/lib/gems

Please help me to resolve this error and install rails successfully.I also have another doubt here.After installing ruby when i chcked the version it is showing me the ruby version 2.1.7 but here i need ruby version 2.1.5.Please also help me do this.I am using Ubuntu 14.0 version.

Upvotes: 0

Views: 67

Answers (1)

vjdhama
vjdhama

Reputation: 5078

The issue might be because the gem executable is not installed in user directory.

You can confirm this using which gem.

Run this command for installing rails.

sudo gem install rails --version=4.2.0

UPDATE:

The error : Errror: Error installing rails Error: failed to build gem native extension might be because of lack of dev-headers.

Try running this :

sudo apt-get install ruby2.1-dev

These errors are the reasons you should probably try using rbenv or rvm to install ruby and rails.

Upvotes: 2

Related Questions