Re: New Perl-Installation on new OS X

2011-06-10 Thread David Cantrell
On Thu, Jun 09, 2011 at 12:43:43PM +0200, Marek Stepanek wrote:

 But perhaps this list could help me, to get @INC and $PERL5LIB clean of 
 /sw ... How is it possible, that I have $PERL5LIB set to
 
 %ENV:
 PERL5LIB=/sw/lib/perl5:/sw/lib/perl5/darwin
 
 in [my .profile] I only have one line:
 
   test -r /sw/bin/init.sh  . /sw/bin/init.sh

So you're wondering where the /sw/wibble is coming from, and you've
found something mentioning /sw/wibble in your .profile.  D'you think
they might be related?

Several fixes come to mind:

1. delete that line from .profile.  This will, however, prevent anything
   else that it does from happening.

2. edit /sw/bin/init.sh to prevent it from messing with PERL5LIB.

3. save PERL5LIB before that line and restore it afterwards.

4. just set PERl5LIB to whatever you fancy after that line.  This will,
   however, mean that you override any changes that may be made to your
   startup files elsewhere at a later date.

-- 
David Cantrell | Reality Engineer, Ministry of Information

  Blessed are the pessimists, for they test their backups


Re: New Perl-Installation on new OS X

2011-06-10 Thread John Delacour

At 11:45 +0100 10/06/2011, David Cantrell wrote:


Several fixes come to mind:
...
4. just set PERl5LIB to whatever you fancy after that line.  This will,
   however, mean that you override any changes that may be made to your
   startup files elsewhere at a later date.


What would be the effect of setting a value (or no value) for 
PERL5LIB in ~/.MacOSX/environment.plist?  Would that override 
anything written to .profile etc.?


JD


Re: New Perl-Installation on new OS X

2011-06-10 Thread Sherm Pendley
On Fri, Jun 10, 2011 at 10:34 AM, John Delacour j...@bd8.com wrote:
 At 11:45 +0100 10/06/2011, David Cantrell wrote:

 Several fixes come to mind:
 ...
 4. just set PERl5LIB to whatever you fancy after that line.  This will,
   however, mean that you override any changes that may be made to your
   startup files elsewhere at a later date.

 What would be the effect of setting a value (or no value) for PERL5LIB in
 ~/.MacOSX/environment.plist?

That plist is for setting up environment variables for GUI apps. It
has no effect on shell sessions.

sherm--

-- 
Cocoa programming in Perl:
http://camelbones.sourceforge.net


Re: New Perl-Installation on new OS X

2011-06-10 Thread John Delacour

At 10:38 -0400 10/06/2011, Sherm Pendley wrote:


  What would be the effect of setting a value (or no value) for PERL5LIB in

 ~/.MacOSX/environment.plist?


That plist is for setting up environment variables for GUI apps. It
has no effect on shell sessions.


Obviously I'm missing something.  If I do set it, it seems to have 
the same effect superficially as fink's exporting it via 
.profile/init.sh, which I thought was the problem:


perl -V
  Compiled at Jan 26 2010 17:48:53
  %ENV:
PERL5LIB=/usr/local/lib/perl5/site_perl/5.14.0
  @INC:
/usr/local/lib/perl5/site_perl/5.14.0
/Library/Perl/Updates/5.10.0/darwin-thread-multi-2level

perl -e 'print $ENV{PERL5LIB}'
/usr/local/lib/perl5/site_perl/5.14.0

JD


Re: New Perl-Installation on new OS X

2011-06-10 Thread Doug McNutt
At 10:38 -0400 6/10/11, Sherm Pendley wrote:
On Fri, Jun 10, 2011 at 10:34 AM, John Delacour j...@bd8.com wrote:
 What would be the effect of setting a value (or no value) for PERL5LIB in
 ~/.MacOSX/environment.plist?

That plist is for setting up environment variables for GUI apps. It
has no effect on shell sessions.

That's not the case for 10.3.9. Has it changed?

I have been defining $PERL5LIB and some other stuff  in environment.plist for 
years mostly because of AppleScripts I like to use. Most of the scripts are 
executed with osascript from a shell and they work fine with no additional 
redefinition in .tcshrc.

They also work OK when I log in to 10.3.9  from a Linux box or use bbedit 
worksheets.

I always thought environment.plist was just a way to be sure things were set 
immediately after the sort of login that is used to start up the machine rather 
than waiting for a shell style login.
-- 

-- A fair tax is one that you pay but I don't --


Re: New Perl-Installation on new OS X

2011-06-10 Thread Sherm Pendley
On Fri, Jun 10, 2011 at 11:11 AM, John Delacour j...@bd8.com wrote:
 At 10:38 -0400 10/06/2011, Sherm Pendley wrote:

   What would be the effect of setting a value (or no value) for PERL5LIB
 in

  ~/.MacOSX/environment.plist?

 That plist is for setting up environment variables for GUI apps. It
 has no effect on shell sessions.

 Obviously I'm missing something.  If I do set it, it seems to have the same
 effect superficially as fink's exporting it via .profile/init.sh

Yes, but since .profile is evaluated later, whatever it does will
override what's set in the plist. Thus, changes in the plist will have
no effect on shell sessions that set the same variable.

Nor, as far as I can tell, will anything the OP does with respect to
his @INC. My best guess about that his unable to create a
distribution object relates to many of the files under ~/.cpan being
owned by root. This whole Fink/@INC/PERL5LIB subthread is little more
than a pointless distraction that won't solve the OP's actual problem.

sherm--

-- 
Cocoa programming in Perl:
http://camelbones.sourceforge.net


Re: New Perl-Installation on new OS X

2011-06-10 Thread David Cantrell
On Fri, Jun 10, 2011 at 04:11:43PM +0100, John Delacour wrote:
 At 10:38 -0400 10/06/2011, Sherm Pendley wrote:
   What would be the effect of setting a value (or no value) for PERL5LIB 
  in
  ~/.MacOSX/environment.plist?
 That plist is for setting up environment variables for GUI apps. It
 has no effect on shell sessions.
 Obviously I'm missing something.  If I do set it, it seems to have 
 the same effect ...

Are you using Terminal.app?  That's a GUI application, so it takes
effect, and is then inherited by the shell.  Try sshing into your
Mac from elsewhere.

-- 
David Cantrell | Enforcer, South London Linguistic Massive

PERL: Politely Expressed Racoon Love


Re: New Perl-Installation on new OS X

2011-06-10 Thread John Delacour

At 16:47 +0100 10/06/2011, David Cantrell wrote:


Are you using Terminal.app?  That's a GUI application, so it takes
effect, and is then inherited by the shell.  Try sshing into your
Mac from elsewhere.


Right.  I ran a script from cgi-bin on my local server and indeed 
this key was missing.  The same script run in BBEdit had it.  All 
clear.  Thanks.


JD


RE: New Perl-Installation on new OS X

2011-06-10 Thread Jan Dubois
On Fri, 10 Jun 2011, Sherm Pendley wrote:
 Yes, but since .profile is evaluated later, whatever it does will
 override what's set in the plist. Thus, changes in the plist will have
 no effect on shell sessions that set the same variable.

I use this line in my .bash_profile to make sure I use the
same PATH everywhere (and only have to edit it in one place):

export PATH=`/usr/libexec/PlistBuddy -c 'Print :PATH' 
~/.MacOSX/environment.plist`

The same can be done for PERL5LIB.

Cheers,
-Jan




Re: New Perl-Installation on new OS X

2011-06-10 Thread Sherm Pendley
On Fri, Jun 10, 2011 at 2:27 PM, Jan Dubois j...@activestate.com wrote:
 On Fri, 10 Jun 2011, Sherm Pendley wrote:
 Yes, but since .profile is evaluated later, whatever it does will
 override what's set in the plist. Thus, changes in the plist will have
 no effect on shell sessions that set the same variable.

 I use this line in my .bash_profile to make sure I use the
 same PATH everywhere (and only have to edit it in one place):

 export PATH=`/usr/libexec/PlistBuddy -c 'Print :PATH' 
 ~/.MacOSX/environment.plist`

 The same can be done for PERL5LIB.

It can be - and I've copied that into my Collection of Handy Stuff. :-)

But the question is, should it be done for PERL5LIB? That affects
*all* Perls, and if you've included the path to modules compiled for
(say) 5.12, but you're running 5.10, those modules won't work.

That's exactly the problem that bit Fink some time ago - their init.sh
used PERL5LIB to add their Perl module directories, which had modules
they'd compiled with 5.6 - when Apple then released a version of Mac
OS X that used Perl 5.8.1, those Fink-provided modules no longer
worked. There was much wailing and gnashing of teeth over Fink
breaking Apple's Perl, but in fact they didn't do that; they hadn't
touched Apple's Perl at all, they had simply told *all* Perls to look
for modules that only some Perls would be able to use.

sherm--

-- 
Cocoa programming in Perl:
http://camelbones.sourceforge.net


RE: New Perl-Installation on new OS X

2011-06-10 Thread Jan Dubois
On Fri, 10 Jun 2011, Sherm Pendley wrote:
 But the question is, should it be done for PERL5LIB? That affects
 *all* Perls, and if you've included the path to modules compiled for
 (say) 5.12, but you're running 5.10, those modules won't work.

Ah, yes, sorry, lost track of the real topic of the thread.

I think a better way to modify your @INC is on a per-installation
basis.  For Apple's Perl you have the AppendToPath and PrependToPath
mechanism, e.g.

$ cat /Library/Perl/5.10.0/AppendToPath 
/System/Library/Perl/Extras/5.10.0

There is no PrependToPath file by default, but you can create one
yourself, and all directories listed in there will be put at the
front of @INC, just as if you put them into PERL5LIB.

If you build your own Perl, then you may want to ./Configure it
with -Dusesitecustomize.  That way you can modify @INC in a
perl/site/lib/sitecustomize.pl file at runtime.

ActivePerl uses this mechanism to add a per-user install directory
to @INC:

$ cat /usr/local/ActivePerl-5.14/site/lib/sitecustomize.pl 
# ~/Library/ActivePerl-5.14 is the default location for PPM install
# So make sure we look for modules there
if (my $home = (getpwuid($))[7]) {
my $lib = $home/Library/ActivePerl-5.14/lib;
unless (grep { $_ eq $lib } @INC) {
# Insert $lib just ahead of 'site/lib' so that overrides
# via $ENV{PERL5LIB} or 'perl -I...' still works
(my $site = __FILE__) =~ s,/sitecustomize\.pl\z,,;
my $i = $#INC;
$i-- while $i  0  $INC[$i] ne $site;
splice(@INC, $i, 0, $lib);
}
}

This sitecustomize.pl script is a little more complicated because
it inserts the directory behind the ones specified with PERL5LIB
and -I, but before the builtin ones:

$ PERL5LIB=~/mylib perl -E 'say for @INC'
/Users/jan/mylib
/Users/jan/Library/ActivePerl-5.14/lib
/usr/local/ActivePerl-5.14/site/lib
/usr/local/ActivePerl-5.14/lib
.

So again, you can customize your @INC setup for each Perl installation
independently without resorting to global environment variables, which
will just get in the way at the wrong time...

Cheers,
-Jan




RE: New Perl-Installation on new OS X

2011-06-10 Thread John Delacour

At 13:21 -0700 10/06/2011, Jan Dubois wrote:


I think a better way to modify your @INC is on a per-installation
basis.  For Apple's Perl you have the AppendToPath and PrependToPath
mechanism...
There is no PrependToPath file by default, but you can create one
yourself, and all directories listed in there will be put at the
front of @INC, just as if you put them into PERL5LIB.

If you build your own Perl, then you may want to ./Configure it
with -Dusesitecustomize.  That way you can modify @INC in a
perl/site/lib/sitecustomize.pl file at runtime.


Very useful information, Jan.  Many thanks.

JD