Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gem install permission problem

qichunren@zhaobak:~> gem install hpricot ERROR:  While executing gem ... (Gem::FilePermissionError)     You don't have write permissions into the /opt/ruby-enterprise-1.8.7/lib/ruby/gems/1.8 directory. 

Current login user is qichunren, and qichunre user have write permission with .gem dir.I would like to know why gem not install files into my home .gem dir first? Why my gem common first want to install files into /opt/ruby-enterprise-1.8.7/lib/ruby/gems/1.8

like image 360
qichunren Avatar asked Apr 12 '10 03:04

qichunren


People also ask

How do I install gem packages?

With the --local ( -l ) option, you would perform a local search through your installed gems. To install a gem, use gem install [gem] . Browsing installed gems is done with gem list . For more information about the gem command, see below or head to RubyGems' docs.

How do I install a downloaded GEM file?

In the console be located in the gems cache (cd [Ruby Installation version]/lib/ruby/gems/[Ruby version]/cache ) and fire the gem install anygemwithdependencieshere (by example cucumber-2.99. 0 )

How does gem install work?

What does gem install do? gem install , in its simplest form, does something kind of like this. It grabs the gem and puts its files into a special directory on your system. You can see where gem install will install your gems if you run gem environment (look for the INSTALLATION DIRECTORY: line):


1 Answers

Try setting GEM_HOME and GEM_PATH to ~/.gem,

For the current terminal session, just type:

export GEM_HOME=~/.gem export GEM_PATH=~/.gem 

If you want these to be set whenever you open a terminal, add the above commands to your ~/.bashrc file.

For a more comprehensive solution to setting up a custom ruby environment, see this tutorial from Site5KB, which describes using a .gemrc file.

like image 120
meagar Avatar answered Sep 22 '22 00:09

meagar