Accessing gems from /home dir

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?



I would set the environment variable (in .bashrc)


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


On Apr 26, 12:55 pm, Dan Z. [email protected] wrote:


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



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

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
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.



jzakiya wrote:

    from /usr/bin/gem:9




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

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:
exec /usr/bin/ruby -I/my/load/path “[email protected]

(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.


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs