Pg gem: LoadError

Hello,

I spent a good deal of time trying to get the “pg” installed on my Mac
OSX 10.6.8. I finally got it successfully installed and using require
‘pg’ in irb returns true:

require ‘pg’
=> true

However, when I make a file called temp and the only line is

require ‘pg’

I get this message after running “ruby temp”:

temp:1:in `require’: no such file to load – pg (LoadError)
from temp:1

What am I missing?

Thanks!

Subject: pg gem: LoadError
Date: mar 27 ago 13 06:35:17 +0200

Quoting Smash Y. ([email protected]):

require ‘pg’

I get this message after running “ruby temp”:

temp:1:in `require’: no such file to load – pg (LoadError)
from temp:1

What am I missing?

I have no access to any mac. But:

Did you execute both irb and ruby from the same username? Maybe you
have leftovers from multiple installations of Ruby. What do you get
with

ls -l which irb

and

ls -l which ruby

? It might be useful to know which procedure you followed to compile
and install the postgres extension.

Carlo

So I found out what the problem was. I discovered it in another random
thread on another random forum. Turns out you have to

require ‘rubygems’

before you require anything else on Ruby 1.8. It works now.