# Accessing gems from /home dir

**URL:** <https://www.ruby-forum.com/t/accessing-gems-from-home-dir/93023>\
**Category:** Ruby\
**Created:** [April 26, 2007, 6:06pm UTC](https://www.ruby-forum.com/t/accessing-gems-from-home-dir/93023 "2007-04-26T18:06:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jzakiya](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3ec8ea/32.png) [@jzakiya](https://www.ruby-forum.com/u/jzakiya)\
**Post date:** [April 26, 2007, 6:06pm UTC](https://www.ruby-forum.com/t/accessing-gems-from-home-dir/93023/1 "2007-04-26T18:06:04Z")

</div>

I have Linux on a Toshiba Satellite laptop.

In my home dir I’m running Ruby 1.8.6.  
In my root dir I have Ruby 1.8.4 which was  
installed from my distro’s (PCLinuxOS) repositories.

All my gems are loaded and run under root/1.8.4 control.  
I cannot access these gems from my home dir with 1.8.6.

What do I need to do to be able to access these gems  
from my home dir with 1.8.6?

Thanks

jz

---

<div class="post-metadata">

**Author:** ![jzakiya](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3ec8ea/32.png) [@jzakiya](https://www.ruby-forum.com/u/jzakiya)\
**Post date:** [April 26, 2007, 6:56pm UTC](https://www.ruby-forum.com/t/accessing-gems-from-home-dir/93023/2 "2007-04-26T18:56:09Z")

</div>

I would set the environment variable (in .bashrc)

GEM\_HOME=

where is the directory with the folders: cache doc gems  
specifications. I’m not positive it will work, but I do this on my  
computer (for the opposite setup, with a central ruby install and gems  
in my home dir), and it works fine. Note that rubygems has some bugs and  
may not always pay attention to this environment variable when it  
should…

Dan

---

<div class="post-metadata">

**Author:** ![jzakiya](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3ec8ea/32.png) [@jzakiya](https://www.ruby-forum.com/u/jzakiya)\
**Post date:** [April 29, 2007, 7:36pm UTC](https://www.ruby-forum.com/t/accessing-gems-from-home-dir/93023/3 "2007-04-29T19:36:19Z")

</div>

On Apr 26, 12:55 pm, Dan Z. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Dan
> 
> > What do I need to do to be able to access these gems  
> > from my home dir with 1.8.6?
> 
> > Thanks
> 
> > jz

I set the GEM\_HOME variable as you suggested, but no luck.

Here’s more detail into the nature of the problem.

I can run both versions of ruby from my [home] as such:

[home]$ /usr/bin/ruby -v  
ruby 1.8.4 (2005-12-24) [i586-linux-gnu]

[home]$ ruby -v (or /usr/local/bin/ruby -v)  
ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-linux]

No problem ro run gem as root:

[root]# gem -v  
0.9.2

But if I try to run gem from my [home], problems:

[home]$ gem -v (or /usr/bin/gem -v)  
/usr/bin/gem:9:in `require’: no such file to load – rubygems  
(LoadError)  
from /usr/bin/gem:9

I put a symbolic link in my /usr/local/bin; ln -s /usr/bin/gem gem  
but that wouldn’t let me run gem from [home] either.

Is this a rubygems problem?  
Do I have to put a separate copy of rubygems in my [home] dir for it  
to work there?

I also looked into the rubyconfig.rb file, but it didn’t seem that  
needed any change.

HELP!

jz

---

<div class="post-metadata">

**Author:** ![jzakiya](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3ec8ea/32.png) [@jzakiya](https://www.ruby-forum.com/u/jzakiya)\
**Post date:** [April 30, 2007, 12:56am UTC](https://www.ruby-forum.com/t/accessing-gems-from-home-dir/93023/4 "2007-04-30T00:56:48Z")

</div>

jzakiya wrote:

> ```
> from /usr/bin/gem:9
> 
> ```
> 
> HELP!
> 
> jz

jz,

First off, it might be useful to note whether root and your user account  
are actually running the same version of gem by running “which gem” as  
user and as root.

But more importantly, it looks like when you are running “gem”, it’s  
trying to include a file, “rubygems.rb”, that it can’t find. I would  
guess your load paths aren’t configured correctly. I’ll suggest a  
solution, but there’s probably a better way to do this. My way feels a  
little (okay, a lot) hackish:

I want to add a certain directory to my include path, and I don’t ever  
want to have to worry about doing it on the command line or modifying my  
files. So:

$ ./somescript.rb  
is the same as  
$ ruby ./somescript.rb  
right?

We want to use the -I option to add a directory to the load path. So:  
$ ruby ./somescript.rb -I/usr/lib/ruby/site

But I still want to be able to run it without explicitly typing “ruby”.  
And I don’t want to start each of my scripts with #!/usr/bin/ruby  
-I/my/load/path, because that would be cumbersome.

So I continue to start the files with #!/usr/bin/env ruby  
but I create a script in $HOME/bin (which is before /usr/bin in my path,  
so $HOME/bin/ruby gets called, not /usr/bin/ruby). The script only says:  
#!/bin/bash  
exec /usr/bin/ruby -I/my/load/path “$@”

(Of course, replace /usr/bin/ruby with the path to the executable that  
you want to run.) That way, every time you start a file with  
#!/usr/bin/env ruby, the right (eventually) executable gets called with  
an argument that tells it where to look for include files. You’ll need  
to find this path on your own system, as it’s different on different  
distros. I’d start with “locate rubygems.rb”.

Good luck, I hope this wasn’t too confusing. If anybody reading this has  
a really clean solution (like an environment variable that I don’t know  
about), I’d love to hear about it.

Dan
