February 9th, 2013, 12:56 PM
How to set paths used by CPAN on SuSE machine?
I have a program I built to do some work with files we receive on our FTP server (SuSE 9.0) and use them to make changes to a Postgresql database on another system. When I first ran it, I discovered that I did not have the DBD::Pg module I needed to interact with our database on it - my test server had no problems, but we didn't use postgres on the FTP server for anything previously.
Attempting to use CPAN to get the module in question returns an error, which I have attempted to copy in full (from the start of the error segment) below:
Okay, turns out the FTP machine did have a copy of Postgres 7.3 on it. I didn't think that would be a big problem - I could simply download a more up-to-date copy of postgres and install it, and things would be good.
CPAN.pm: Going to build T/TU/TURNSTEP/DBD-Pg-2.19.3.tar.gz
Configuring DBD::Pg 2.19.3
PostgreSQL version: 70304 (default port: 5432)
POSTGRES_HOME: (not set)
WARNING! DBD::Pg no longer supports versions less than 7.4.
You must upgrade PostgreSQL to a newer version.
Running make test
Make had some problems, maybe interrupted? Won't test
Running make install
Make had some problems, maybe interrupted? Won't install
I've done so - from source install of Postgres 8.3.23, added the path to my $PATH variable, and verified that running psql shows as version 8.3.23. However, this version of Postgres installed to a different directory than the previous one did, and I think I've managed to miss something in the path settings - I'm still getting the same error as above in CPAN when I try to download the DBD::Pg module.
What do I need to do to alter the path settings, either of my own path variable or of CPAN's path searching, to have it point to the new version of Postgres (or whatever libraries it may want from that) instead of the old one?
February 10th, 2013, 10:10 AM
Can only answer in general terms since I don't use SUSE.
There are a few hints in the DBD::Pg README file.
So you can define those environment variables right in the shell before you run CPAN. The other variables mentioned in your post should be set also, but they are only needed for the automated tests.
As far as having two versions of postgres on one machine, if that wasn't intended, you can edit the postgres makefile to specify where you want the install to occur. Just add the --prefix option when running configure. List of options in the docs.
If you are running two versions of postgres on the same machine, you can run them both at the same time by setting one to use a different port, or you can only run one at a time. You will have to choose which method to use.
Although you can set the environment variables directly from the command line and get CPAN to find the desired version of postgres this time, remember that as soon as that shell session ends, the environment variables will be lost. The next time you log in you will have to set them again in order to use the right DB by default.
You can avoid that by setting up your shell to define those variables at startup. Example, if you use zsh, you can edit ~/.zshrc to include something like
Whatever the locations are for the version of postgres you want to use.
If you or a program does not specify the full path, this path variable is used to look for a match. By putting the path to the new version of postgres first, that's the one that will be found when you simply type something like 'psql'.