Ruby-postgres gem installation on Leopard

Hi all

I am just about to start a project using rails and am trying to setup
my enviroment with postgres as the database. I have installed postgres
8.3.1 from source and am now having trouble installing the ruby-
postgres gem. The following is the output trace I am getting, looks
like a problem with headers/includes, any help is greatly appreciated.

Thanks
Simon

sudo gem install ruby-postgres – --with-pgsql-include-dir=/usr/local/
pgsql/include/ --with-pgsql-lib-dir=/usr/local/pgsql/lib/

Building native extensions. This could take a while…
ERROR: Error installing ruby-postgres:
ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
extconf.rb install ruby-postgres – --with-pgsql-include-dir=/usr/
local/pgsql/include/ --with-pgsql-lib-dir=/usr/local/pgsql/lib/
checking for main() in -lpq… yes
checking for libpq-fe.h… yes
checking for libpq/libpq-fs.h… yes
checking for PQsetClientEncoding()… no
checking for pg_encoding_to_char()… no
checking for PQfreemem()… no
checking for PQescapeString()… no
creating Makefile

make
gcc -I. -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/
usr/lib/ruby/1.8/universal-darwin9.0 -I. -DHAVE_LIBPQ_FE_H -
DHAVE_LIBPQ_LIBPQ_FS_H -I/usr/local/pgsql/include -fno-common -arch
ppc -arch i386 -Os -pipe -fno-common -Wall -c libpq-compat.c
libpq-compat.c: In function ‘PQescapeBytea’:
libpq-compat.c:104: warning: implicit declaration of function
‘sprintf’
libpq-compat.c:104: warning: incompatible implicit declaration of
built-in function ‘sprintf’
libpq-compat.c:104: warning: pointer targets in passing argument 1 of
‘sprintf’ differ in signedness
libpq-compat.c: In function ‘PQunescapeBytea’:
libpq-compat.c:158: warning: implicit declaration of function ‘strlen’
libpq-compat.c:158: warning: incompatible implicit declaration of
built-in function ‘strlen’
libpq-compat.c:158: warning: pointer targets in passing argument 1 of
‘strlen’ differ in signedness
libpq-compat.c: In function ‘PQescapeBytea’:
libpq-compat.c:104: warning: implicit declaration of function
‘sprintf’
libpq-compat.c:104: warning: incompatible implicit declaration of
built-in function ‘sprintf’
libpq-compat.c:104: warning: pointer targets in passing argument 1 of
‘sprintf’ differ in signedness
libpq-compat.c: In function ‘PQunescapeBytea’:
libpq-compat.c:158: warning: implicit declaration of function ‘strlen’
libpq-compat.c:158: warning: incompatible implicit declaration of
built-in function ‘strlen’
libpq-compat.c:158: warning: pointer targets in passing argument 1 of
‘strlen’ differ in signedness
gcc -I. -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/
usr/lib/ruby/1.8/universal-darwin9.0 -I. -DHAVE_LIBPQ_FE_H -
DHAVE_LIBPQ_LIBPQ_FS_H -I/usr/local/pgsql/include -fno-common -arch
ppc -arch i386 -Os -pipe -fno-common -Wall -c postgres.c
postgres.c: In function ‘pgconn_s_escape_bytea’:
postgres.c:370: warning: pointer targets in passing argument 1 of
‘PQescapeBytea’ differ in signedness
postgres.c: In function ‘pgconn_s_escape_bytea’:
postgres.c:370: warning: pointer targets in passing argument 1 of
‘PQescapeBytea’ differ in signedness
postgres.c: In function ‘pgconn_s_unescape_bytea’:
postgres.c:401: warning: pointer targets in passing argument 1 of
‘PQunescapeBytea’ differ in signedness
postgres.c: In function ‘pgconn_s_unescape_bytea’:
postgres.c:401: warning: pointer targets in passing argument 1 of
‘PQunescapeBytea’ differ in signedness
postgres.c: In function ‘Init_postgres’:
postgres.c:2593: error: ‘pgconn_protocol_version’ undeclared (first
use in this function)
postgres.c:2593: error: (Each undeclared identifier is reported only
once
postgres.c:2593: error: for each function it appears in.)
postgres.c:2594: error: ‘pgconn_server_version’ undeclared (first use
in this function)
postgres.c: In function ‘Init_postgres’:
postgres.c:2593: error: ‘pgconn_protocol_version’ undeclared (first
use in this function)
postgres.c:2593: error: (Each undeclared identifier is reported only
once
postgres.c:2593: error: for each function it appears in.)
postgres.c:2594: error: ‘pgconn_server_version’ undeclared (first use
in this function)
lipo: can’t open input file: /var/tmp//ccOm8KcD.out (No such file or
directory)
make: *** [postgres.o] Error 1

Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/ruby-
postgres-0.7.1.2006.04.06 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/ruby-
postgres-0.7.1.2006.04.06/gem_make.out

On Jun 12, 8:38 am, “simon.m.fox” [email protected] wrote:

Hi all

I am just about to start a project using rails and am trying to setup
my enviroment with postgres as the database. I have installed postgres
8.3.1 from source and am now having trouble installing the ruby-
postgres gem. The following is the output trace I am getting, looks
like a problem with headers/includes, any help is greatly appreciated.

As you can seen in the trace, that gem is quite old (april 2006) i’m
guessing it just doesn’t work with postgres 8.3. There are
unfortunately a plethora of postgres gems, but two that are still
actively (if i remember correctly; not a big postgres user) are
postgres (whose rubyforge project is ruby-postgres, sigh…) and ruby-
pg (which is the latest and greatest).
I believe i’m correct in saying that a few tweaks to the activerecord
adapter were needed for ruby-pg, so you should only use ruby-pg if you
will be running rails 2.1 or higher.

Fred