Failure building PL/Ruby on MacOS X 10.3

G

Gavin Kistner

I have Ruby 1.8.1, PostgreSQL 7.4.1, mod_ruby 1.1.2, eRuby 1.0.5,
postgres 0.7.1, and Apache 2.0.48 installed and playing nicely together.

One final piece...I want PL/Ruby in my PGSQL. But it's not liking me:

[Slim:local/src/plruby-0.3.8] root# ruby extconf.rb
--with-pgsql-dir=/usr/local/pgsql
--with-pgsql-srcinc=/usr/local/src/postgresql-7.4.1/src/include/

checking for ruby_init() in -lruby-static... yes
checking for catalog/pg_proc.h... yes
checking for PQsetdbLogin() in -lpq... yes
creating Makefile

[Slim:local/src/plruby-0.3.8] root# make
gcc -fno-common -I/usr/local/src/postgresql-7.4.1/src/include/
-I/usr/local/pgsql/include/postgresql/server -DPG_PL_VERSION=74 -I.
-I/usr/local/lib/ruby/1.8/powerpc-darwin
-I/usr/local/lib/ruby/1.8/powerpc-darwin -I. -DHAVE_CATALOG_PG_PROC_H
-I/usr/local/pgsql/include -c plruby.c
In file included from plruby.c:47:
plruby.h:27:32: server/utils/array.h: No such file or directory
plruby.c: In function `return_array_type':
plruby.c:894: error: `ArrayType' undeclared (first use in this function)
plruby.c:894: error: (Each undeclared identifier is reported only once
plruby.c:894: error: for each function it appears in.)
plruby.c:894: error: `array' undeclared (first use in this function)
plruby.c: In function `pl_func_handler':
plruby.c:1380: error: `ArrayType' undeclared (first use in this function)
plruby.c:1380: error: `array' undeclared (first use in this function)
plruby.c:1384: error: parse error before ')' token
plruby.c:1386: warning: assignment makes pointer from integer without a cast
plruby.c:1391: warning: assignment makes pointer from integer without a cast
make: *** [plruby.o] Error 1


[Slim:local/src/plruby-0.3.8] root# uname -a
Darwin Slim.local 7.2.0 Darwin Kernel Version 7.2.0: Thu Dec 11 16:20:23
PST 2003; root:xnu/xnu-517.3.7.obj~1/RELEASE_PPC Power Macintosh powerpc

[Slim:local/src/plruby-0.3.8] root# /usr/local/pgsql/bin/postgres --version
postgres (PostgreSQL) 7.4.1

[Slim:local/src/plruby-0.3.8] root# ruby --version
ruby 1.8.1 (2004-02-17) [powerpc-darwin]




I *do* see /src/include/utils/array.h ... did the src hierarchy for
PGSQL change and the make file needs to be updated to match?

Any thoughts on how I can get this built?
 
G

Gavin Kistner

Gavin said:
I *do* see /src/include/utils/array.h ... did the src hierarchy for
PGSQL change and the make file needs to be updated to match?

Further information:
I tried editing plruby.h to point to the array.h file I saw:


#if PG_PL_VERSION >= 74
- #include "server/utils/array.h"
+ #include "utils/array.h"
#endif

And hey! It compiled OK!
But then...awww...it fails just about every test with 'make test'.

Output follows.


[Slim:local/src/plruby-0.3.8] root# ruby extconf.rb
--with-pgsql-dir=/usr/local/pgsql
--with-pgsql-srcinc=/usr/local/src/postgresql-7.4.1/src/include
checking for ruby_init() in -lruby-static... yes
checking for catalog/pg_proc.h... yes
checking for PQsetdbLogin() in -lpq... yes
creating Makefile

[Slim:local/src/plruby-0.3.8] root# make
gcc -fno-common -I/usr/local/src/postgresql-7.4.1/src/include
-I/usr/local/pgsql/include/postgresql/server -DPG_PL_VERSION=74 -I.
-I/usr/local/lib/ruby/1.8/powerpc-darwin
-I/usr/local/lib/ruby/1.8/powerpc-darwin -I. -DHAVE_CATALOG_PG_PROC_H
-I/usr/local/pgsql/include -c plruby.c
cc -dynamic -bundle -undefined suppress -flat_namespace
-L'/usr/local/lib' -L'/usr/local/pgsql/lib' -o plruby.bundle plruby.o
-lpq -lruby-static -ldl -lobjc

[Slim:local/src/plruby-0.3.8] root# make test
(cd test/plt ; sh ./runtest 74)
**** Destroy old database plruby_test ****
../runtest: line 9: dropdb: command not found
**** Create test database plruby_test ****
../runtest: line 15: createdb: command not found
**** Create procedural language plruby ****
../runtest: line 19: psql: command not found
**** Create tables, functions and triggers ****
../runtest: line 22: psql: command not found
**** Running test queries ****
Tests faild - look at diffs between
test.expected.74 and test.out
(cd test/plp ; sh ./runtest 74)
**** Destroy old database plruby_test ****
../runtest: line 9: dropdb: command not found
**** Create test database plruby_test ****
../runtest: line 15: createdb: command not found
**** Create procedural language plruby ****
../runtest: line 19: psql: command not found
**** Create tables, functions and triggers ****
../runtest: line 22: psql: command not found
**** Running test queries ****
Tests faild - look at diffs between
test.expected.74 and test.out
(cd test/range; sh ./runtest 74)
**** Destroy old database plruby_test ****
../runtest: line 8: dropdb: command not found
**** Create test database plruby_test ****
../runtest: line 11: createdb: command not found
**** Create procedural language plruby ****
../runtest: line 15: psql: command not found
**** Running test queries ****
Tests faild - look at diffs between
test.expected.74 and test.out
[Slim:local/src/plruby-0.3.8] root# make install
install -c -p -m 0755 plruby.bundle
/usr/local/lib/ruby/site_ruby/1.8/powerpc-darwin
[Slim:local/src/plruby-0.3.8] root# make test
(cd test/plt ; sh ./runtest 74)
**** Destroy old database plruby_test ****
../runtest: line 9: dropdb: command not found
**** Create test database plruby_test ****
../runtest: line 15: createdb: command not found
**** Create procedural language plruby ****
../runtest: line 19: psql: command not found
**** Create tables, functions and triggers ****
../runtest: line 22: psql: command not found
**** Running test queries ****
Tests faild - look at diffs between
test.expected.74 and test.out
(cd test/plp ; sh ./runtest 74)
**** Destroy old database plruby_test ****
../runtest: line 9: dropdb: command not found
**** Create test database plruby_test ****
../runtest: line 15: createdb: command not found
**** Create procedural language plruby ****
../runtest: line 19: psql: command not found
**** Create tables, functions and triggers ****
../runtest: line 22: psql: command not found
**** Running test queries ****
Tests faild - look at diffs between
test.expected.74 and test.out
(cd test/range; sh ./runtest 74)
**** Destroy old database plruby_test ****
../runtest: line 8: dropdb: command not found
**** Create test database plruby_test ****
../runtest: line 11: createdb: command not found
**** Create procedural language plruby ****
../runtest: line 15: psql: command not found
**** Running test queries ****
Tests faild - look at diffs between
test.expected.74 and test.out
 
A

Ara.T.Howard

Further information:
I tried editing plruby.h to point to the array.h file I saw:


#if PG_PL_VERSION >= 74
- #include "server/utils/array.h"
+ #include "utils/array.h"
#endif

And hey! It compiled OK!
But then...awww...it fails just about every test with 'make test'.

export PATH=/usr/local/pgsql/bin:$PATH

this is probably why it can't fine the commands (assuming they are there)

you may also want to

export LD_LIBRARY_PATH=/usr/local/pgsql/lib:$LD_LIBRARY_PATH

actually - i'd do a

export LD_RUN_PATH=/usr/local/pgsql/lib

__before__ compiling and.

do a man ld

HTH.

-a

Output follows.


[Slim:local/src/plruby-0.3.8] root# ruby extconf.rb
--with-pgsql-dir=/usr/local/pgsql
--with-pgsql-srcinc=/usr/local/src/postgresql-7.4.1/src/include
checking for ruby_init() in -lruby-static... yes
checking for catalog/pg_proc.h... yes
checking for PQsetdbLogin() in -lpq... yes
creating Makefile

[Slim:local/src/plruby-0.3.8] root# make
gcc -fno-common -I/usr/local/src/postgresql-7.4.1/src/include
-I/usr/local/pgsql/include/postgresql/server -DPG_PL_VERSION=74 -I.
-I/usr/local/lib/ruby/1.8/powerpc-darwin
-I/usr/local/lib/ruby/1.8/powerpc-darwin -I. -DHAVE_CATALOG_PG_PROC_H
-I/usr/local/pgsql/include -c plruby.c
cc -dynamic -bundle -undefined suppress -flat_namespace
-L'/usr/local/lib' -L'/usr/local/pgsql/lib' -o plruby.bundle plruby.o
-lpq -lruby-static -ldl -lobjc

[Slim:local/src/plruby-0.3.8] root# make test
(cd test/plt ; sh ./runtest 74)
**** Destroy old database plruby_test ****
./runtest: line 9: dropdb: command not found
**** Create test database plruby_test ****
./runtest: line 15: createdb: command not found
**** Create procedural language plruby ****
./runtest: line 19: psql: command not found
**** Create tables, functions and triggers ****
./runtest: line 22: psql: command not found
**** Running test queries ****
Tests faild - look at diffs between
test.expected.74 and test.out
(cd test/plp ; sh ./runtest 74)
**** Destroy old database plruby_test ****
./runtest: line 9: dropdb: command not found
**** Create test database plruby_test ****
./runtest: line 15: createdb: command not found
**** Create procedural language plruby ****
./runtest: line 19: psql: command not found
**** Create tables, functions and triggers ****
./runtest: line 22: psql: command not found
**** Running test queries ****
Tests faild - look at diffs between
test.expected.74 and test.out
(cd test/range; sh ./runtest 74)
**** Destroy old database plruby_test ****
./runtest: line 8: dropdb: command not found
**** Create test database plruby_test ****
./runtest: line 11: createdb: command not found
**** Create procedural language plruby ****
./runtest: line 15: psql: command not found
**** Running test queries ****
Tests faild - look at diffs between
test.expected.74 and test.out
[Slim:local/src/plruby-0.3.8] root# make install
install -c -p -m 0755 plruby.bundle
/usr/local/lib/ruby/site_ruby/1.8/powerpc-darwin
[Slim:local/src/plruby-0.3.8] root# make test
(cd test/plt ; sh ./runtest 74)
**** Destroy old database plruby_test ****
./runtest: line 9: dropdb: command not found
**** Create test database plruby_test ****
./runtest: line 15: createdb: command not found
**** Create procedural language plruby ****
./runtest: line 19: psql: command not found
**** Create tables, functions and triggers ****
./runtest: line 22: psql: command not found
**** Running test queries ****
Tests faild - look at diffs between
test.expected.74 and test.out
(cd test/plp ; sh ./runtest 74)
**** Destroy old database plruby_test ****
./runtest: line 9: dropdb: command not found
**** Create test database plruby_test ****
./runtest: line 15: createdb: command not found
**** Create procedural language plruby ****
./runtest: line 19: psql: command not found
**** Create tables, functions and triggers ****
./runtest: line 22: psql: command not found
**** Running test queries ****
Tests faild - look at diffs between
test.expected.74 and test.out
(cd test/range; sh ./runtest 74)
**** Destroy old database plruby_test ****
./runtest: line 8: dropdb: command not found
**** Create test database plruby_test ****
./runtest: line 11: createdb: command not found
**** Create procedural language plruby ****
./runtest: line 15: psql: command not found
**** Running test queries ****
Tests faild - look at diffs between
test.expected.74 and test.out

--
===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
| URL :: http://www.ngdc.noaa.gov/stp/
| TRY :: for l in ruby perl;do $l -e "print \"\x3a\x2d\x29\x0a\"";done
===============================================================================
 
D

David Garamond

Gavin said:
I have Ruby 1.8.1, PostgreSQL 7.4.1, mod_ruby 1.1.2, eRuby 1.0.5,
postgres 0.7.1, and Apache 2.0.48 installed and playing nicely together.
[snip]

plruby.h:27:32: server/utils/array.h: No such file or directory

I'm not familiar with the packaging system used in Mac OS X, but have
you installed the 'postgresql-devel' package (which contains the
necessary *.h files)? If yes, then check the correct path for
server/utils/array.h (e.g. is it really in
/usr/local/src/postgresql-7.4.1/src/include/?)
 
G

Gavin Kistner

Ara.T.Howard said:
export PATH=/usr/local/pgsql/bin:$PATH

this is probably why it can't fine the commands (assuming they are there)

Indeed, the problem (as I realized when I inspected the error messages
and thought a bit) was that the pgsql commands weren't in my path.

When I put them there, I got new errors with 'make test', which I
believe had to do with the fact that it was invoking psql without a
database name, which was thus looking for a database named 'root' (the
user I was running as).

I decided that make test was full of bunk, and went on and installed the
compiled code. I'm happy to report, PL/Ruby is working nicely :)


So, in summary (for the record/archives):

In order to build PL/Ruby 0.3.8 to work with PostgreSQL 7.4.1 (the
standard .tar.gz source, not some special package for OS X) I had to
change one line in plruby.h from
#include "server/utils/array.h"
to
#include "utils/array.h"

After that, I needed (not unexpectedly) to explicitly specify the paths
to pgsql (built version and source includes):

ruby extconf.rb --with-pgsql-dir=/usr/local/pgsql
--with-pgsql-srcinc=/usr/local/src/postgresql-7.4.1/src/include


After the above, making and installing the code worked:
make
make install

And I just had to ignore the fact that make test didn't work at all.
 
G

Gavin Kistner

David said:
I'm not familiar with the packaging system used in Mac OS X, but have
you installed the 'postgresql-devel' package (which contains the
necessary *.h files)? If yes, then check the correct path for
server/utils/array.h (e.g. is it really in
/usr/local/src/postgresql-7.4.1/src/include/?)

FWIW, this was not a MacOS X specific package. It was precisely:

ftp://ftp9.us.postgresql.org/pub/mirrors/postgresql/source/v7.4.1/postgresql-base-7.4.1.tar.gz

which has array.h inside /src/include/utils/ and *not*
/src/include/server/utils/

Dunno when this changed, but seems to be a minor broken part of the
PL/Ruby install.
 
T

ts

G> which has array.h inside /src/include/utils/ and *not*
G> /src/include/server/utils/

svg% cat pgsql/data/PG_VERSION
7.4
svg%

svg% find pgsql -name array.h
pgsql/include/server/utils/array.h
svg%

G> Dunno when this changed, but seems to be a minor broken part of the
G> PL/Ruby install.

svg% less plruby-0.3.8/README.en
[...]

For PostgreSQL 7.2 the source is not required if all headers was installed.
Command (see INSTALL in the directory postgresql-7.2)

make install-all-headers
[...]
svg%

it's not my fault if `make install-all-headers' put the file in
include/server/utils/ and not in include/utils/


Guy Decoux
 
A

Ara.T.Howard

After that, I needed (not unexpectedly) to explicitly specify the paths
to pgsql (built version and source includes):

ruby extconf.rb --with-pgsql-dir=/usr/local/pgsql
--with-pgsql-srcinc=/usr/local/src/postgresql-7.4.1/src/include


After the above, making and installing the code worked:
make
make install

be careful - if you run ldd on the postgres.so lib you'll probably see
something like

[ahoward@www i686-linux]$ ldd postgres.so
libpq.so.3 => /usr/lib/libpq.so.3 (0x40012000)
libnsl.so.1 => /lib/libnsl.so.1 (0x40027000)
libdl.so.2 => /lib/libdl.so.2 (0x4003c000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0x4003f000)
libm.so.6 => /lib/tls/libm.so.6 (0x4006c000)
libc.so.6 => /lib/tls/libc.so.6 (0x42000000)
libssl.so.4 => /lib/libssl.so.4 (0x4008f000)
libcrypto.so.4 => /lib/libcrypto.so.4 (0x400c4000)
libkrb5.so.3 => /usr/kerberos/lib/libkrb5.so.3 (0x401b5000)
libresolv.so.2 => /lib/libresolv.so.2 (0x40213000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)
libgssapi_krb5.so.2 => /usr/kerberos/lib/libgssapi_krb5.so.2 (0x40225000)
libk5crypto.so.3 => /usr/kerberos/lib/libk5crypto.so.3 (0x40239000)
libcom_err.so.3 => /usr/kerberos/lib/libcom_err.so.3 (0x40249000)
libz.so.1 => /usr/lib/libz.so.1 (0x4024b000)

except in your case you will probably see

libpq.so.3 => /usr/local/lib/libpq.so.3 (0x40012000)
^^^^^
^^^^^

that's _ok_, but on many linuxes this dir is NOT in the system search path for
ld.so (cat /etc/ld.so.conf). it MAY be in your environment or it may be set
globally somehow. what i'm saying is that the ruby postgres.so depends on the
linker being able to find the required postgresql libraries at runtime. the
way it does this is by

* standard ld.so search path
* contents of /etc/ld.so.conf
* paths encoded into postgres.so itself
* contents of LD_LIBRARY_PATH

i realize your setup may be slightly different. all i'm saying is be sure the
way the linker finds the postgresql is set in some _global_ way or some users
(say the web using - nobody or www) may have unexpected errors when doing a

require 'postgres'

i'm spewing all this because i spent some time at one point determining the
cause of exactly this problem when all my cgi programs failed to load the
postgres lib. the easiest answer is to

~ > export LD_RUN_PATH=/usr/local/pgsql/lib
~ > ruby extconf.rb --with-pgsql-dir=/usr/local/pgsql \
--with-pgsql-srcinc=/usr/local/src/postgresql-7.4.1/src/include
~ > make
~ > make install

-a
--
===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
| URL :: http://www.ngdc.noaa.gov/stp/
| TRY :: for l in ruby perl;do $l -e "print \"\x3a\x2d\x29\x0a\"";done
===============================================================================
 
G

Gavin Kistner

ts said:
For PostgreSQL 7.2 the source is not required if all headers was installed.
Command (see INSTALL in the directory postgresql-7.2)

make install-all-headers
it's not my fault if `make install-all-headers' put the file in
include/server/utils/ and not in include/utils/

Well, there's our confusion, then. :)

I didn't make pgsql with all headers. The includes directory I was
pointing it was was not (in my case)

/usr/local/pgsql/include/

but rather

/usr/local/src/postgresql-7.4.1/src/include/

If you mean to require that postgresql be installed with all headers for
plruby to build properly, then I think the above needs rewording.

But if it is acceptable--when the user (me) hasn't installed pgsql with
all headers--to point plruby at the headers in the original source
directory for postegresql, then something needs to change slightly in
the header to account for the fact that array.h exists in a sub
'include/server/utils/' directory when installed with pgsql, but is out
in the open in 'include/utils/' in the original source.

Anyhow, all is working now for me. Thanks for a great tool! :)
 
T

ts

G> If you mean to require that postgresql be installed with all headers for
G> plruby to build properly, then I think the above needs rewording.


Well, the next version will test the directory. Just to give you an
example, the include directories for 7.3 and 7.4 are

svg% ls /home/ts/local/pg73/include
ecpgerrno.h ecpgtype.h libpq-fe.h pg_config_os.h postgresql/ sqlca.h
ecpglib.h libpq/ pg_config.h postgres_ext.h sql3types.h
svg%

svg% ls /home/ts/local/pgsql/include
ecpg_informix.h internal/ pg_config_os.h pgtypes_timestamp.h
ecpgerrno.h libpq/ pgtypes_date.h postgres_ext.h
ecpglib.h libpq-fe.h pgtypes_error.h server/
ecpgtype.h pg_config.h pgtypes_interval.h sql3types.h
informix/ pg_config_manual.h pgtypes_numeric.h sqlca.h
svg%

See the directory server and postgresql, the installation was make with
the same commands (I've just given a different directory for --prefix)

The include tree change for each version :-(((


Guy Decoux
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,962
Messages
2,570,134
Members
46,690
Latest member
MacGyver

Latest Threads

Top