Perl error, once and for all

Bradley Giesbrecht brad at pixilla.com
Tue Mar 3 11:49:12 PST 2009


On Mar 3, 2009, at 7:55 AM, Vincent Lefevre wrote:

> On 2009-03-03 07:30:18 -0800, Bradley Giesbrecht wrote:
>> On Mar 1, 2009, at 5:11 PM, Vincent Lefevre wrote:
>>>> if [ -n "$PERL5LIB" ]; then
>>>> PERL5LIB="${PERL5LIB}:/opt/local/lib/perl5/vendor_perl"
>>>> else
>>>> export PERL5LIB
>>>> PERL5LIB="/opt/local/lib/perl5/vendor_perl"
>>>> fi
>>
>> My path to p5's looks like this:
>> 	/opt/local/lib/perl5/vendor_perl/5.8.9/
>>
>> Wouldn't the full path including the version dir need to be added to
>> PERL5LIB?
>
> I don't know whether this has changed in Perl 5.8.9 (I haven't
> upgraded yet), but with previous versions, the version dir should
> not be used in $PERL5LIB, as perl automatically adds the paths so
> that modules installed with previous versions can still be used.
> For instance:
>
> $ perl -V
> [...]
>  %ENV:
>    PERL5LIB="/Users/vinc17/lib/site_perl:/opt/local/lib/perl5/ 
> vendor_perl"
>  @INC:
>    /Users/vinc17/lib/site_perl/darwin-2level
>    /Users/vinc17/lib/site_perl
>    /opt/local/lib/perl5/vendor_perl/5.8.8/darwin-2level
>    /opt/local/lib/perl5/vendor_perl/5.8.8
>    /opt/local/lib/perl5/vendor_perl/5.8.7/darwin-2level
>    /opt/local/lib/perl5/vendor_perl/5.8.7
>    /opt/local/lib/perl5/vendor_perl
>    /opt/local/lib/perl5/5.8.8/darwin-2level
>    /opt/local/lib/perl5/5.8.8
>    /opt/local/lib/perl5/site_perl/5.8.8/darwin-2level
>    /opt/local/lib/perl5/site_perl/5.8.8
>    /opt/local/lib/perl5/site_perl/5.8.7/darwin-2level
>    /opt/local/lib/perl5/site_perl/5.8.7
>    /opt/local/lib/perl5/site_perl
>    /opt/local/lib/perl5/vendor_perl/5.8.8/darwin-2level
>    /opt/local/lib/perl5/vendor_perl/5.8.8
>    /opt/local/lib/perl5/vendor_perl/5.8.7/darwin-2level
>    /opt/local/lib/perl5/vendor_perl/5.8.7
>    /opt/local/lib/perl5/vendor_perl

# export
Adding export PERL5LIB=/opt/local/lib/perl5/vendor_perl
   @INC:
     /opt/local/lib/perl5/vendor_perl/5.8.9/darwin-thread-multi-2level
     /opt/local/lib/perl5/vendor_perl/5.8.9
     /opt/local/lib/perl5/vendor_perl
     /opt/local/lib/perl5/5.8.9/darwin-thread-multi-2level
     /opt/local/lib/perl5/5.8.9
     /opt/local/lib/perl5/site_perl/5.8.9/darwin-thread-multi-2level
     /opt/local/lib/perl5/site_perl/5.8.9
     /opt/local/lib/perl5/site_perl
     /opt/local/lib/perl5/vendor_perl/5.8.9/darwin-thread-multi-2level
     /opt/local/lib/perl5/vendor_perl/5.8.9
     /opt/local/lib/perl5/vendor_perl
     .

I don't have site_perl on my system so I'll assume that's something  
you added in one way or another.


>> Are you suggesting using this in Portfiles?
>
> Either the Portfile could provide the necessary options (I don't know
> which ones) to change the default @INC in the perl binary (with the
> advantage that modifying the environment variable won't be necessary)
> or the PERL5LIB variable needs to be changed in the .profile (either
> by MacPorts (base?) or by the user).

It would be nice to not have to change .profile. If a system has  
multiple users or a user is added later this would be one more thing  
that would need to be done.

Maybe we could add a port "macports-profile" that would be a script  
similar to:
/opt/local/share/macports/setupenv.bash

with the addition of checking for perl5 activation among others.

And then instead making a many alterations to a users .profile we  
would just add one:
. /opt/local/sbin/macports_profile

The macports_profile script would always append it's vars to the front  
of existing vars so if PERL5LIB is already set in the users .profile  
it would be maintained the the macports paths prepended.

I suppose the file /opt/local/etc/maports_profile.conf could be looked  
for and if found could be parsed for overrides and additions.

Then if a new user is added they could run /opt/local/sbin/ 
macports_profile which would check the users .profile file and add the  
source line if it's missing.

This is just an idea, the names and locations of the files might not  
be great. Heck, the whole idea might be flawed.

>> If I have perl5.8 active and install a p5 and then deactivate perl5.8
>> and activate perl5.10 should I expect my p5 to be active and  
>> functional?
>
> I haven't tried. See the "perl -V" output without the version number
> in $PERL5LIB.


Works.

I have a macports on my laptop that I'm keeping clean just to help  
resolve this perl5 issue. I hope we can come up with a work solution  
soon. Even if it's just the decision to instruct users to add PERL5LIB  
to their .profile by hand.

Oh, and what about other shells? Let that small base work it out  
themselves as they are probably used to doing?

//Brad


More information about the macports-users mailing list