Skip Menu |

This queue is for tickets about the User CPAN distribution.

Report information
The Basics
Id: 7109
Status: resolved
Worked: 1 hour (60 min)
Priority: 0/
Queue: User

People
Owner: metaperl [...] gmail.com
Requestors:
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: test.pl - chdir() won't go $ENV{HOME} on win32
generally on win32 $ENV{HOME} is not set. You need to set it to $ENV{USERPROFILE} temporarily during the test.
[guest - Mon Jul 26 07:41:46 2004]: Show quoted text
> generally on win32 $ENV{HOME} is not set. > You need to set it to $ENV{USERPROFILE} temporarily during the test.
did the test fail? the method ->Home() will use USERPROFILE if it cannot fine HOME
[TBONE - Thu Dec 16 16:44:07 2004]: Show quoted text
> [guest - Mon Jul 26 07:41:46 2004]: >
> > generally on win32 $ENV{HOME} is not set. > > You need to set it to $ENV{USERPROFILE} temporarily during the test.
> > did the test fail? the method ->Home() will use USERPROFILE if it cannot > fine HOME
in fact, the tests passed on 40 different systems, so I think it works... http://search.cpan.org/~tbone/User-1.6/
From: m.nooning [...] comcast.net
Show quoted text
> in fact, the tests passed on 40 different systems, so I think it works... > http://search.cpan.org/~tbone/User-1.6/
How many successes a test has does not negate any failures. The original ticketer of two years ago is correct. The fact is, on Windows XP Home edition at least, chdir() does not change the directory unless $ENV{HOME} is set, which it is not by default. Your test script therefore will fail by default on Windows XP Home edition machines. For Windows 2K and above, $ENV{USERPROFILE} is defined by default, so on Windows 2K and above, chdir($ENV{USERPROFILE}) will work, as will setting $ENV{HOME} prior to the test. Show quoted text
> did the test fail?
Yes. However, User.pm clearly works, so I installed it anyway. It is only the test that is faulty. In case there are doubts about this, I will now paste a short test script, and then paste the results. Notice the "uninitialized value" in the results, which of course refer to the first attempt at printing $ENV{HOME}. --------------paste script #!/usr/bin/perl -w use Cwd qw( getcwd abs_path); use strict; chdir("C:\\temp\\"); my $oldpwd = getcwd; chdir(); my $newpwd = getcwd; print ("oldpwd is $oldpwd\n"); print ("newpwd is $newpwd\n"); print ("ENV HOME is ", $ENV{HOME}, "\n"); print ("ENV USERPROFILE is ", $ENV{USERPROFILE}, "\n"); $ENV{HOME} = $ENV{USERPROFILE} if ($^O eq 'MSWin32'); chdir(); my $lastpwd = getcwd; print ("lastpwd is $lastpwd\n"); --------------end paste script ----------paste results C:\temp>perl test.pl oldpwd is C:/temp newpwd is C:/temp Use of uninitialized value in print at test.pl line 14. ENV HOME is ENV USERPROFILE is C:\Documents and Settings\malcolm lastpwd is C:/Documents and Settings/malcolm ----------end paste results Thanks
From: TBONE [...] cpan.org
On Sat Apr 07 13:17:28 2007, m.nooning@comcast.net wrote: Show quoted text
> > in fact, the tests passed on 40 different systems, so I think it
works... Show quoted text
> > How many successes a test has does not negate any failures. > > The original ticketer of two years ago is correct. The fact is, on > Windows XP Home edition at least, chdir() does not change the directory > unless $ENV{HOME} is set, which it is not by default. Your test script > therefore will fail by default on Windows XP Home edition machines. > > For Windows 2K and above, $ENV{USERPROFILE} is defined by default, so on > Windows 2K and above, chdir($ENV{USERPROFILE}) will work, as will > setting $ENV{HOME} prior to the test.
Ok, I have access to a Win XP box at work, so I will get to this Monday... Thanks for the script.
From: TBONE [...] cpan.org
I'd like to make sure of the Perl distribution you are using. Is it ActiveState Perl? Under Cygwin $ENV{HOME} is in fact defined. On Sat Apr 07 13:17:28 2007, m.nooning@comcast.net wrote: Show quoted text
> > in fact, the tests passed on 40 different systems, so I think it
works... Show quoted text
> > How many successes a test has does not negate any failures. > > The original ticketer of two years ago is correct. The fact is, on > Windows XP Home edition at least, chdir() does not change the directory > unless $ENV{HOME} is set, which it is not by default. Your test script > therefore will fail by default on Windows XP Home edition machines. > > For Windows 2K and above, $ENV{USERPROFILE} is defined by default, so on > Windows 2K and above, chdir($ENV{USERPROFILE}) will work, as will > setting $ENV{HOME} prior to the test. >
> > did the test fail?
> Yes. However, User.pm clearly works, so I installed it anyway. It is > only the test that is faulty. > > In case there are doubts about this, I will now paste a short test > script, and then paste the results. Notice the "uninitialized value" in > the results, which of course refer to the first attempt at printing > $ENV{HOME}. > > --------------paste script > #!/usr/bin/perl -w > > use Cwd qw( getcwd abs_path); > use strict; > > chdir("C:\\temp\\"); > my $oldpwd = getcwd; > chdir(); > my $newpwd = getcwd; > > print ("oldpwd is $oldpwd\n"); > print ("newpwd is $newpwd\n"); > > print ("ENV HOME is ", $ENV{HOME}, "\n"); > print ("ENV USERPROFILE is ", $ENV{USERPROFILE}, "\n"); > > $ENV{HOME} = $ENV{USERPROFILE} if ($^O eq 'MSWin32'); > chdir(); > my $lastpwd = getcwd; > print ("lastpwd is $lastpwd\n"); > --------------end paste script > > ----------paste results > C:\temp>perl test.pl > oldpwd is C:/temp > newpwd is C:/temp > Use of uninitialized value in print at test.pl line 14. > ENV HOME is > ENV USERPROFILE is C:\Documents and Settings\malcolm > lastpwd is C:/Documents and Settings/malcolm > ----------end paste results > > Thanks
On Sat Apr 07 13:17:28 2007, m.nooning@comcast.net wrote: Show quoted text
> > in fact, the tests passed on 40 different systems, so I think it
works... Show quoted text
> > How many successes a test has does not negate any failures.
true! Show quoted text
> > The original ticketer of two years ago is correct. The fact is, on > Windows XP Home edition at least, chdir() does not change the directory > unless $ENV{HOME} is set, which it is not by default. Your test script > therefore will fail by default on Windows XP Home edition machines. > > For Windows 2K and above, $ENV{USERPROFILE} is defined by default, so on > Windows 2K and above, chdir($ENV{USERPROFILE}) will work, as will > setting $ENV{HOME} prior to the test.
OK, I see: just stick a $ENV{HOME} = $ENV{USERPROFILE} in before the chdir() call so the test passes.
RT-Send-CC: m.nooning [...] comcast.net
Ok, I added $ENV{HOME} = $ENV{USERPROFILE} if ($^O eq 'MSWin32') ; just before the chdir() and it now works on Win XP Media Center edition when it was failing with your supplied test just before the fix. Thanks, you are given credit in the AUTHOR section of the 1.8 upload to CPAN..