login community faq

I want to install a gem locally (not as part of a rails app though) but it requires a higher version of rubygems.
gem update --system doesn't work though since it tries to use the system ruby.

1
2
3
4
5
6
7
8
9
$ gem update --system   
Updating RubyGems  
Updating rubygems-update  
Successfully installed rubygems-update-1.4.2  
:0:Warning: Gem::SourceIndex#search support for String patterns is deprecated  
Updating RubyGems to 1.4.2  
Installing RubyGems 1.4.2  
ERROR:  While executing gem ... (Errno::EACCES)  
    Permission denied - /usr/local/lib/ruby/site_ruby/1.8/rbconfig/datadir.rb

However this added:/home/username/gems/gems/rubygems-update-1.4.2/

I added this in my .bash_profile:

1
2
export GEM_HOME=$PWD/gems  
export PATH="$PWD/bin:$PATH"

(logged out/in) and ran

1
2
3
4
$ which gem  
~/bin/gem  
$ gem -v  
1.3.1

This makes me think it's using the gem command in my local folder. gem update -system still doesn't work but using the folder it downloaded above:

1
2
3
4
5
$ gem install rubygems-update
Successfully installed rubygems-update-1.4.2
1 gem installed
Installing ri documentation for rubygems-update-1.4.2...
Installing RDoc documentation for rubygems-update-1.4.2...

But it still says it's version 1.3.1. Where is it installing 1.4.2? Am I even close?

asked Jan 26 '11 at 22:14

joeminkie's gravatar image

joeminkie
1112


So, after searching around some more, I found this: http://forum.webfaction.com/viewtopic.php?id=4918 and installed my own ruby version. Then I tried to install rubygems but got this error:

1
require': no such file to load -- rubygems (LoadError)

Eventually I found this: http://docs.rubygems.org/read/chapter/19#page98 and copied the following files from ~/lib to ~/ruby/lib/ruby/site_ruby/1.8

1
2
3
4
5
gauntlet_rubygems.rb
rubyconfig/
rubygems/
rubygems.rb
ubygems.rb

Everything seems to be working for now...

answered Jan 27 '11 at 20:13

joeminkie's gravatar image

joeminkie
1112

Glad to hear you were able to figure it out.

(Jan 27 '11 at 20:17) johns ♦♦ johns's gravatar image

Here's how we recommend installing RubyGems locally. This assumes that your Passenger-based Rails app is named "rails" and that your username is "your_username":

In a SSH session, run the following commands:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
cd ~/webapps/rails
export GEM_HOME=$PWD/gems
export PATH=$PWD/bin:$PATH
export RUBYLIB=$PWD/lib:$RUBYLIB
mkdir src
cd src
wget http://production.cf.rubygems.org/rubygems/rubygems-1.5.2.tgz
tar zxf rubygems-1.5.2.tgz
cd rubygems-1.5.2
ruby setup.rb install --prefix=$HOME/webapps/rails

Then, edit ~/webapps/rails/nginx/conf/nginx.conf to add this line to the beginning of the file:

1
env               RUBYLIB=/home/your_username/webapps/rails/lib;

Then, edit ~/webapps/rails/bin/start to add the RUBYLIB environment variable to the start command, eg:

1
RUBYLIB=/home/your_username/webapps/rails/lib TMPDIR=/home/your_username/webapps/rails/tmp GEM_HOME=/home/your_username/webapps/rails/gems /home/your_username/webapps/rails/nginx/sbin/nginx -p /home/your_username/webapps/rails/nginx/

Finally, restart your Nginx:

1
~/webapps/rails/bin/restart

That's it, you're done :)

This answer is marked "community wiki".

answered Feb 25 '11 at 19:45

seanf's gravatar image

seanf ♦♦
55991220

edited Feb 25 '11 at 19:50

Your answer
If you have an answer to the above question, then use the form below. Otherwise, use the appropriate 'add new comment' button above to post your feedback.
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×61
×56
×7

Asked: Jan 26 '11 at 22:14

Seen: 4,321 times

Last updated: Feb 25 '11 at 19:50

Plans & prices    Sign up    Why WebFaction?    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
Powered by OSQA
© Copyright 2003-2012 Swarma Limited - WebFaction is a service of Swarma Limited