View Full Version : Ruby Gems
philz
10-15-2006, 06:03 PM
Is it possible to install extra Ruby gems?
It seems to be theoretically possible to have a custom installation of Ruby Gems under your home directory, or even just a custom gem repository. Take a look at http://rubygems.org/read/chapter/3#page83.
If it's possible to have a local repository without adding a custom installation of Ruby Gems, it may just be as simple as creating a directory for the gem repository and adding
export GEM_HOME=/home/myusername/mygemrepository
to ".bash_profile". If that worked, then you could install as many extra gems as you wanted. You'd probably have to reinstall all the regular gems in your new custom repository, though.
raavin
10-15-2006, 11:07 PM
I haven't actually tried it on hostmonster yet but you can get a rake task from http://nubyonrails.com/articles/2005/12/22/freeze-other-gems-to-rails-lib-directory which will freeze your gem in the lib directory.
Alternatively you can put in a support request to get them to install it for you. You need to supply your domain and a link to the website for your gem.
Raavin ;)
OK, I decided to try my own advice:
cd ~/local
mkdir gems
export GEM_HOME=$HOME/local/gems
gem query --local
This gives me a blank listing of local gems.
*** LOCAL GEMS ***
Then I tried
gem query --remote
Unfortunately, that spewed out a bunch of errors. Whoops! I'm on the right track, though. I'll post again if I get it to work. I don't have time to continue this experiment this morning.
On second thought, starting with an empty repository is a mistake, because you need the "sources" package to do easy remote installation. Hence the errors. It's better to start with the host repository as a base. Here's my updated instructions for creating a local gem repository (without building RubyGems from source). Make sure ~/local/gems does not exist already or use a different directory.
First, copy the host repository to your local directory in SSH.
cd ~/local
mkdir gems
cp -r /lib/ruby/gems/1.8 ./gems
Second, add the following line to "~/.bash_profile"
export GEM_HOME=$HOME/local/gems
If you want, check to make sure it's working and install the progressbar gem:
gem query --local
gem query --remote
gem install progressbar
From there you should be able to add as many gems as you need.
Mathieu
04-14-2007, 11:40 AM
Thanks alot for the answer. Saved me alot of time
nanalq
07-22-2007, 08:20 PM
I tried to follow your example however when i try to install a gem i get
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /usr/lib/ruby/gems/1.8/cache/ferret-0.11.3.gem
can anyone help me ??
vBulletin® v3.8.4, Copyright ©2000-2010, Jelsoft Enterprises Ltd.