Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 9th, 2013, 11:56 AM
EnderX EnderX is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2009
Posts: 59 EnderX User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 5 h 28 m 12 sec
Reputation Power: 4
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:

Code:
  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)
POSTGRES_INCLUDE: /usr/include/pgsql
POSTGRES_LIB: /usr/lib
OS: linux

****************
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


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.

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?

Reply With Quote
  #2  
Old February 10th, 2013, 09:10 AM
keath's Avatar
keath keath is offline
!~ /m$/
Dev Shed Specialist (4000 - 4499 posts)
 
Join Date: May 2004
Location: Reno, NV
Posts: 4,086 keath User rank is General 12nd Grade (Above 100000 Reputation Level)keath User rank is General 12nd Grade (Above 100000 Reputation Level)keath User rank is General 12nd Grade (Above 100000 Reputation Level)keath User rank is General 12nd Grade (Above 100000 Reputation Level)keath User rank is General 12nd Grade (Above 100000 Reputation Level)keath User rank is General 12nd Grade (Above 100000 Reputation Level)keath User rank is General 12nd Grade (Above 100000 Reputation Level)keath User rank is General 12nd Grade (Above 100000 Reputation Level)keath User rank is General 12nd Grade (Above 100000 Reputation Level)keath User rank is General 12nd Grade (Above 100000 Reputation Level)keath User rank is General 12nd Grade (Above 100000 Reputation Level)keath User rank is General 12nd Grade (Above 100000 Reputation Level)keath User rank is General 12nd Grade (Above 100000 Reputation Level)keath User rank is General 12nd Grade (Above 100000 Reputation Level)keath User rank is General 12nd Grade (Above 100000 Reputation Level)keath User rank is General 12nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 6 h 59 m 11 sec
Reputation Power: 1809
Can only answer in general terms since I don't use SUSE.

There are a few hints in the DBD::Pg README file.

Quote:
By default Makefile.PL uses App::Info to find the location of the
PostgreSQL library and include directories. However, if you want to
control it yourself, define the environment variables POSTGRES_INCLUDE
and POSTGRES_LIB, or define just POSTGRES_HOME. Note that if you have
compiled PostgreSQL with SSL support, you must define the POSTGRES_LIB
environment variable and add "-lssl" and "-lcrypto" to it, like this:

export POSTGRES_LIB="/usr/local/pgsql/lib -lssl -lcrypto"


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.

Quote:
The tests rely on being able to connect to a valid Postgres database.
The easiest way to ensure this is to set the following environment variables:

DBI_DSN=dbi:Pg:dbname=<database>
DBI_USER=<username>
DBI_PASS=<password>

If you are running on a non-standard port, you must set PGPORT or
add the port to the DBI_DSN variable like this:

DBI_DSN='dbi:Pg:dbname=<database>;port=<port#>'


---

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
Code:
export PGDATA="/data/pgdata"
export PGHOME="/usr/lib/pgsql"
export PATH="$PGHOME/bin/:$PATH"


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'.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > How to set paths used by CPAN on SuSE machine?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap