# Rubygems can't find gems

**URL:** <https://www.ruby-forum.com/t/rubygems-cant-find-gems/115832>\
**Category:** Ruby\
**Created:** [September 28, 2007, 10:48pm UTC](https://www.ruby-forum.com/t/rubygems-cant-find-gems/115832 "2007-09-28T22:48:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mortee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/50afbb/32.png) [@mortee](https://www.ruby-forum.com/u/mortee)\
**Post date:** [September 28, 2007, 10:48pm UTC](https://www.ruby-forum.com/t/rubygems-cant-find-gems/115832/1 "2007-09-28T22:48:21Z")

</div>

Hi,

I have a problem with rubygems on a OS X 10.4.10 Tiger PPC. Ruby 1.8.6  
and rubygems 0.9.4 are installed properly. Ruby is installed through  
fink so I set PREFIX to /sw. I installed rubygems by

PREFIX=/sw  
export GEM\_HOME=$PREFIX/lib/ruby/gems/1.8  
export RUBYLIB=$PREFIX/lib/ruby:$PREFIX/lib/site\_ruby/1.8  
sudo ruby setup.rb all --prefix=$PREFIX

so it should be aware of the repository path. I installed some gems, the  
gem list command shows them as expected.

I have -rubygems in RUBYOPT.

But when I simply require any gem by name, I get a LoadError (on the  
file, not rubygems itself). If I specify the absolute path of the gem’s  
main file to require, it passes without error.

What may be wrong with my setup?

thx  
mortee

---

<div class="post-metadata">

**Author:** ![mortee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/50afbb/32.png) [@mortee](https://www.ruby-forum.com/u/mortee)\
**Post date:** [September 29, 2007, 4:24pm UTC](https://www.ruby-forum.com/t/rubygems-cant-find-gems/115832/2 "2007-09-29T16:24:38Z")

</div>

Replying to myself: it turned out that I was using the wrong way to  
check if I can require the given gem, and actually rubygems works just  
fine. This transformed my problem into another question. What’s the  
difference between the following two cases?

$ ruby -rsome-gem -e ‘puts “ok”’  
ruby: no such file to load – some-gem (LoadError)  
$ ruby -e ‘require “some-gem”; puts “ok”’  
ok  
$

---

<div class="post-metadata">

**Author:** ![mortee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/50afbb/32.png) [@mortee](https://www.ruby-forum.com/u/mortee)\
**Post date:** [September 29, 2007, 6:41pm UTC](https://www.ruby-forum.com/t/rubygems-cant-find-gems/115832/3 "2007-09-29T18:41:48Z")

</div>

mortee wrote:

> > sudo ruby setup.rb all --prefix=$PREFIX  
> > What may be wrong with my setup?
> > 
> > thx  
> > mortee

Before you can require a gem, you must require RubyGems. This occurs  
automatically for you because you have -rubygems in RUBYOPT. However,  
when you using the -r option to require a file, Ruby doesn’t  
automatically require RubyGems, so Ruby can’t find the thing you want to  
require. The only kind of libraries you can require with the -r option  
are libraries that aren’t gems.

I’m pretty sure this limitation will be removed in the next release of  
Ruby.
