Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby gem permission denied /var/lib/gems using Ubuntu

Tags:

ruby

ubuntu

gem

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.

like image 884
Yannick Avatar asked Jul 15 '12 23:07

Yannick


1 Answers

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.

like image 98
Linuxios Avatar answered Sep 20 '22 22:09

Linuxios