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