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

Thanks

jz

···

from my home dir with 1.8.6?

I would set the environment variable (in .bashrc)

GEM_HOME=<gems dir>

where <gems dir> 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

jzakiya wrote:

···

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

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

···

On Apr 26, 12:55 pm, Dan Zwell <dzw...@gmail.com> wrote:

I would set the environment variable (in .bashrc)

GEM_HOME=<gems dir>

where <gems dir> 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

jzakiya wrote:
> 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

jzakiya wrote:

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

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