Bug? File::Temp messing with @INC

M

Matthew Braid

Hi all,

I've recently upgraded to perl 5.8.7 and noticed something that is quite
annoying - File::Temp is fiddling with the order of the paths in @INC
(or at least some library it loads is - haven't quite found the
problematic code).

Example:
perl -e 'use lib "/path/to/my/libs"; print join("\n", @INC), "\n"' /path/to/my/libs
/usr/local/lib/perl5/site_perl/5.8.7/mach
/usr/local/lib/perl5/site_perl/5.8.7
/usr/local/lib/perl5/site_perl/5.8.5
/usr/local/lib/perl5/site_perl
/usr/local/lib/perl5/5.8.7/BSDPAN
/usr/local/lib/perl5/5.8.7/mach
/usr/local/lib/perl5/5.8.7
..

perl -e 'use lib "/path/to/my/libs"; use File::Temp; \
? print join("\n", @INC), "\n"'
/usr/local/lib/perl5/site_perl/5.8.7 <<< Huh?!
/path/to/my/libs <<< Huh?!
/usr/local/lib/perl5/site_perl/5.8.7/mach
/usr/local/lib/perl5/site_perl/5.8.5
/usr/local/lib/perl5/site_perl
/usr/local/lib/perl5/5.8.7/BSDPAN
/usr/local/lib/perl5/5.8.7/mach
/usr/local/lib/perl5/5.8.7
..

Normally this isn't a problem, but I use a custom version of Net::SMTP
that allows setting of the Original-Recipient header, and this no longer
works in some scripts since the 'real' Net::SMTP is loaded instead. I
can of course just go through and make sure File::Temp is loaded either
after Net::SMTP or before another call to 'use lib', but this looks like
very bad behaviour on the part of File::Temp to me.

It could of course be something that File::Temp use's or require's, but
so far I haven't found it by replacing 'use File::Temp' in my test line.

Any ideas? Is this new expected behaviour? A scan of the docs does not
mention @INC at all.

MB
 
A

A. Sinan Unur

? print join("\n", @INC), "\n"'
/usr/local/lib/perl5/site_perl/5.8.7 <<< Huh?!
/path/to/my/libs <<< Huh?!
/usr/local/lib/perl5/site_perl/5.8.7/mach
/usr/local/lib/perl5/site_perl/5.8.5
/usr/local/lib/perl5/site_perl
/usr/local/lib/perl5/5.8.7/BSDPAN
/usr/local/lib/perl5/5.8.7/mach
/usr/local/lib/perl5/5.8.7
.

I can't replicate this behavior with File::Temp version 0.16 and
ActiveState Perl 5.8.7 on Windows.

On the other hand, could you not work around this by putting:

use File::Temp;
use lib '/path/to/my/libs';

that is, by changing the order of the use statements?

Sinan
 
M

Matthew Braid

A. Sinan Unur said:
I can't replicate this behavior with File::Temp version 0.16 and
ActiveState Perl 5.8.7 on Windows.

On the other hand, could you not work around this by putting:

use File::Temp;
use lib '/path/to/my/libs';

that is, by changing the order of the use statements?

Sinan

I'm using File::Temp 0.16 in perl 5.8.7 on FreeBSD....

And yes, that does solve the problem, and I'm shifting code around to do
so, but this looks like a bug to me - I shouldn't have to change code
for an upgrade between versions as close as 5.8.5 and 5.8.7.

MB
 
A

A. Sinan Unur

I'm using File::Temp 0.16 in perl 5.8.7 on FreeBSD....

I can test it on FreeBSD as well, if I get a chance to upgrade Perl on
that machine.
And yes, that does solve the problem, and I'm shifting code around to
do so, but this looks like a bug to me

Might be, which is why I said 'work around'.

Sinan
 
S

Sisyphus

? print join("\n", @INC), "\n"'

For me, produces:
Search pattern not terminated at -e line 1.

If I run:

perl -e 'use lib "/path/to/my/libs"; use File::Temp; print join("\n", @INC),
"\n"'

Then I get the same (correct) output as I do when I run:

perl -e 'use lib "/path/to/my/libs"; print join("\n", @INC), "\n"'

I tested on Linux and Win32 - both running perl 5.8.7. Looks like there are
additional factors involved.

Cheers,
Rob
 
M

Matthew Braid

Sisyphus said:
For me, produces:
Search pattern not terminated at -e line 1.

If I run:

perl -e 'use lib "/path/to/my/libs"; use File::Temp; print join("\n", @INC),
"\n"'

Then I get the same (correct) output as I do when I run:

perl -e 'use lib "/path/to/my/libs"; print join("\n", @INC), "\n"'

I tested on Linux and Win32 - both running perl 5.8.7. Looks like there are
additional factors involved.

Cheers,
Rob

It was a direct capture from my command line - the trailing \ on the
first line is telling my shell to keep reading the next line as part of
the command.

This has gotten even weirder. I copied File/Temp.pm into my home
directory so that:
ll /home/me/tmp/File
total 68
drwxr-xr-x 2 me wheel 512 Jul 14 12:06 ./
drwx------ 4 me wheel 512 Jul 14 12:04 ../
-rw-r--r-- 1 me wheel 64935 Jul 14 12:06 Temp.pm
diff /home/me/tmp/File/Temp.pm /usr/local/lib/perl5/5.8.7/File/Temp.pm
perl -e 'use lib "/home/me/tmp/"; use File::Temp; print "@INC\n";'
/home/me/tmp /usr/local/lib/perl5/site_perl/5.8.7/mach
/usr/local/lib/perl5/site_perl/5.8.7
/usr/local/lib/perl5/site_perl/5.8.5 /usr/local/lib/perl5/site_perl
/usr/local/lib/perl5/5.8.7/BSDPAN /usr/local/lib/perl5/5.8.7/mach
/usr/local/lib/perl5/5.8.7 .
perl -e 'use lib "/home/me/NOTEXIST"; use File::Temp; print "@INC\n"'
/usr/local/lib/perl5/site_perl/5.8.7 /home/me/blah
/usr/local/lib/perl5/site_perl/5.8.7/mach
/usr/local/lib/perl5/site_perl/5.8.5 /usr/local/lib/perl5/site_perl
/usr/local/lib/perl5/5.8.7/BSDPAN /usr/local/lib/perl5/5.8.7/mach
/usr/local/lib/perl5/5.8.7 .

This is just plain out weird. Even though the 'real' File::Temp is
exactly the same as my local copy, only the 'real' one modifies @INC!

Something is extremely wrong here. More digging needed. :(

MB
 
M

Matthew Braid

Matthew said:
total 68
drwxr-xr-x 2 me wheel 512 Jul 14 12:06 ./
drwx------ 4 me wheel 512 Jul 14 12:04 ../
-rw-r--r-- 1 me wheel 64935 Jul 14 12:06 Temp.pm
/home/me/tmp /usr/local/lib/perl5/site_perl/5.8.7/mach
/usr/local/lib/perl5/site_perl/5.8.7
/usr/local/lib/perl5/site_perl/5.8.5 /usr/local/lib/perl5/site_perl
/usr/local/lib/perl5/5.8.7/BSDPAN /usr/local/lib/perl5/5.8.7/mach
/usr/local/lib/perl5/5.8.7 .
/usr/local/lib/perl5/site_perl/5.8.7 /home/me/blah
/usr/local/lib/perl5/site_perl/5.8.7/mach
/usr/local/lib/perl5/site_perl/5.8.5 /usr/local/lib/perl5/site_perl
/usr/local/lib/perl5/5.8.7/BSDPAN /usr/local/lib/perl5/5.8.7/mach
/usr/local/lib/perl5/5.8.7 .

This is just plain out weird. Even though the 'real' File::Temp is
exactly the same as my local copy, only the 'real' one modifies @INC!

Something is extremely wrong here. More digging needed. :(

MB

Oops - I mixed two window's output there - the results of the test with
'use lib "/home/me/NOTEXIST"' included "/home/me/NOTEXIST", not
"/home/me/blah".

MB
 
M

Matthew Braid

Matthew said:
Hi all,

I've recently upgraded to perl 5.8.7 and noticed something that is quite
annoying - File::Temp is fiddling with the order of the paths in @INC
(or at least some library it loads is - haven't quite found the
problematic code).

Example:

? print join("\n", @INC), "\n"'
/usr/local/lib/perl5/site_perl/5.8.7 <<< Huh?!
/path/to/my/libs <<< Huh?!
/usr/local/lib/perl5/site_perl/5.8.7/mach
/usr/local/lib/perl5/site_perl/5.8.5
/usr/local/lib/perl5/site_perl
/usr/local/lib/perl5/5.8.7/BSDPAN
/usr/local/lib/perl5/5.8.7/mach
/usr/local/lib/perl5/5.8.7
.

Normally this isn't a problem, but I use a custom version of Net::SMTP
that allows setting of the Original-Recipient header, and this no longer
works in some scripts since the 'real' Net::SMTP is loaded instead. I
can of course just go through and make sure File::Temp is loaded either
after Net::SMTP or before another call to 'use lib', but this looks like
very bad behaviour on the part of File::Temp to me.

It could of course be something that File::Temp use's or require's, but
so far I haven't found it by replacing 'use File::Temp' in my test line.

Any ideas? Is this new expected behaviour? A scan of the docs does not
mention @INC at all.

MB

OK, found the cause - there are TWO File::Temp's installed on my system.

The first is in /usr/local/lib/perl5/5.8.7/File/Temp.pm. This one is the
'good' one in that it doesn't break @INC, but its never used because of
another one in /usr/local/lib/perl5/site_perl/5.8.7/File/Temp.pm. This
one includes the lines:

use Config;
use lib $Config{'installsitelib'};

Both of these report as being version 0.16.

Does anyone know _why_ there would be two File::Temp's, or why one would
deliberately mess with @INC?!

MB
 
S

Sisyphus

Matthew Braid said:
[snip]


It was a direct capture from my command line - the trailing \ on the
first line is telling my shell to keep reading the next line as part of
the command.

I figured that was the case (and removed it). It was the "?" just before the
"print ..." that both puzzled me and produced the error :)

Cheers,
Rob
 
A

A. Sinan Unur

OK, found the cause - there are TWO File::Temp's installed on my
system.

The first is in /usr/local/lib/perl5/5.8.7/File/Temp.pm. This one is
the 'good' one in that it doesn't break @INC, but its never used
because of another one in
/usr/local/lib/perl5/site_perl/5.8.7/File/Temp.pm. This one includes
the lines:

use Config;
use lib $Config{'installsitelib'};

Both of these report as being version 0.16.

Does anyone know _why_ there would be two File::Temp's, or why one
would deliberately mess with @INC?!

This seems to be due to a patch left-over from a previous build in the
working directory under the ports tree.

asu1@recex:~ > uname -spr
FreeBSD 5.2.1-RELEASE i386

asu1@recex:~ > perl -v
This is perl, v5.8.7 built for i386-freebsd-64int

asu1@recex:~ > perl -MFile::Temp -e 'print qq{$File::Temp::VERSION\n}'
0.16

root@recex:/usr/ports/devel/p5-File-Temp > rm -R files
root@recex:/usr/ports/devel/p5-File-Temp > make deinstall reinstall
clean distclean

asu1@recex:~ > perl -e 'use lib q{/home/asu1}; use File::Temp; print
join(qq{\n}, @INC).qq{\n}'
/home/asu1
/usr/local/lib/perl5/site_perl/5.8.7/mach
/usr/local/lib/perl5/site_perl/5.8.7
/usr/local/lib/perl5/site_perl/5.8.6
/usr/local/lib/perl5/site_perl/5.8.5
/usr/local/lib/perl5/site_perl/5.8.4
/usr/local/lib/perl5/site_perl/5.8.2
/usr/local/lib/perl5/site_perl/5.6.2
/usr/local/lib/perl5/site_perl
/usr/local/lib/perl5/5.8.7/BSDPAN
/usr/local/lib/perl5/5.8.7/mach
/usr/local/lib/perl5/5.8.7
..
 
M

Matthew Braid

A. Sinan Unur said:
This seems to be due to a patch left-over from a previous build in the
working directory under the ports tree.
<snip>

Ah - well there we go :) I'm used to manually installing perl and its
packages and this is the first time I've been involved in a ports
upgrade :) Thanks for that.

MB
 
S

Sisyphus

Matthew Braid said:
Does anyone know _why_ there would be two File::Temp's, or why one would
deliberately mess with @INC?!
I think you'd have to find the person who made that change ask him/her.
There's only one Temp.pm that I could find in the perl 5.8.7 source - it's
version 0.16 and it doesn't load Config.

Cheers,
Rob
 

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,776
Messages
2,569,603
Members
45,201
Latest member
KourtneyBe

Latest Threads

Top