From: Jordi Massaguer Pla Date: 2012-08-30T01:31:05+09:00 Subject: Re: How to add a non standard Gem path? Quoting Iñaki Baz Castillo : > Hi, I would like to install some Gems in a custom directory (i.e. > /usr/local/gems/), so such a directory will have the following > structure: > > ibc@myhost: /usr/local/gems$ ls -l > > drwxr-xr-x 2 root root 4,0K ago 29 18:02 bin/ > drwxr-xr-x 2 root root 4,0K ago 29 18:01 cache/ > drwxr-xr-x 2 root root 4,0K ago 29 18:01 doc/ > drwxr-xr-x 6 root root 4,0K ago 29 18:01 gems/ > drwxr-xr-x 2 root root 4,0K ago 29 18:02 specifications/ > > > Once I've started a Ruby script, how can I tell the "require" command > to include my custom Gem directory so "require GEM_NAME" command looks > first in /usr/local/gems/gems/*/lib/* ? > > > I've tryed modifying the Gem.path which by default has this value: > > Gem.path > => [ "/var/lib/gems/1.9.1", "/home/ibc/.gem/ruby/1.9.1"] > > so I've added my directory: > > Gem.path.insert 0, "/usr/local/gems" > Gem.path > => ["/tmp/gems", "/var/lib/gems/1.9.1", "/home/ibc/.gem/ruby/1.9.1"] > > But this does not work, "require" command does not search there. > > You can try something like this: $:.unshift yourdirectory or use rvm (https://rvm.io/) <- you can use different ruby versions and different gemsets. or use GEM_HOME http://docs.rubygems.org/read/chapter/3 I usually rvm and works very good. regards jordi > > Any help please? > > Thanks a lot. > > > -- > Iñaki Baz Castillo > > >