Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the File-chdir CPAN distribution.

Report information
The Basics
Id: 72924
Status: resolved
Priority: 0/
Queue: File-chdir

People
Owner: Nobody in particular
Requestors: KENTNL [...] cpan.org
Cc:
AdminCc:

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



Subject: Fails t/newline.t on Cygwin
t/newline.t ....... Cannot chdir back to /home/Kent/.cpanm/work/1322950286.4824/File-chdir-0.1006/t/testdir4908: No such file or directory at /home/Kent/.cpanm/work/1322950286.4824/File-chdir-0.1006/lib/File/chdir.pm line 21
Dubious, test returned 2 (wstat 512, 0x200)
No subtests run


So running with a call to system("bash")  immediately after the mkdir call gets me this:

ls -laF t/
total 34
drwxr-xr-x+ 1 Kent None    0 Dec  4 11:16 ./
drwxr-xr-x+ 1 Kent None    0 Dec  4 11:11 ../
-rw-r--r--  1 Kent None 1213 Nov  3 11:11 00-compile.t
-rw-r--r--  1 Kent None 5421 Nov  3 11:11 array.t
-rw-r--r--  1 Kent None 1059 Nov  3 11:11 chdir.t
-rw-r--r--  1 Kent None 2933 Nov  3 11:11 delete-array.t
drwxr-xr-x+ 1 Kent None    0 Nov  3 11:11 lib/
-rw-r--r--  1 Kent None  532 Nov  3 11:11 nested.t
-rw-r--r--  1 Kent None  523 Dec  4 11:16 newline.t
drwxr-xr-x+ 1 Kent None    0 Dec  4 11:16 testdir2008
test/                                                                                             #<-- line feed working
-rw-r--r--  1 Kent None 1493 Nov  3 11:11 var.t

 

 

But trying to chdir/ls into it from shell fails:

ls "testdir2008^Mtest"
test: No such file or directory   

 

The only solution I could find for this was:

 

my $Can_mkdir_With_Newline = mkdir $Test_Dir ;
eval { abs_path($Test_Dir) ; 1 } or undef $Can_mkdir_With_Newline;

 

because abs_path($Test_Dir) triggers "No such file or directory at t/newline.t line 16"

I tried something like

 

my $Can_mkdir_With_Newline = mkdir $Test_Dir  and eval { abs_path($Test_Dir) ; 1 };

 

But that mysteriously doesn't work as I expect it to, so my brain must be off sleeping somewhere.
 

 

Subject: Re: [rt.cpan.org #72924] Fails t/newline.t on Cygwin
Date: Thu, 08 Dec 2011 10:29:11 -0800
To: bug-File-chdir [...] rt.cpan.org
From: Michael G Schwern <schwern [...] pobox.com>
Download (untitled) / with headers
text/plain 735b
On 2011.12.3 2:34 PM, Kent Fredric via RT wrote: Show quoted text
> But trying to chdir/ls into it from shell fails:
Nuts. Show quoted text
> The only solution I could find for this was: > > my $Can_mkdir_With_Newline = mkdir $Test_Dir ; > eval { abs_path($Test_Dir) ; 1 } or undef $Can_mkdir_With_Newline; > > because abs_path($Test_Dir) triggers "No such file or directory at t/newline.t > line 16"
I think that's relying on a quirk of abs_path() which probably chdir's. A better test would be to try to chdir into the directory (and then back to the original). You've got the system that makes it fail at hand, want to take care of the patch and testing it? Also, might want to report to the Cygwin folks that you can make a directory you can't chdir into.
On 2011-12-09 07:29:21, schwern@pobox.com wrote:
Show quoted text
> On 2011.12.3 2:34 PM, Kent Fredric via RT wrote:
> > But trying to chdir/ls into it from shell fails:
>
> Nuts.
>
> Also, might want to report to the Cygwin folks that you can make a
> directory
> you can't chdir into.

On further attempts it appears I *can* chdir into it, just its, well, weird.

Kent@Katipo /tmp
mkdir "$( /bin/echo.exe -ne "bog\nstandard" )"

Kent@Katipo /tmp
cd  "$( /bin/echo.exe -ne "bog\nstandard" )"

Kent@Katipo /tmp/bogstandard
$ echo "$PWD"
/tmp/bog
standard

Kent@Katipo /tmp/bogstandard
$ find $PWD
find: `/tmp/bog': No such file or directory
find: `standard': No such file or directory

Kent@Katipo /tmp/bogstandard
$ find "$PWD"
/tmp/bog?standard
 

In conclusion, I no longer know what the hell it is I am dealing with -_-
 

 


Subject: Re: [rt.cpan.org #72924] Fails t/newline.t on Cygwin
Date: Thu, 08 Dec 2011 19:25:49 -0800
To: bug-File-chdir [...] rt.cpan.org
From: Michael G Schwern <schwern [...] pobox.com>
Download (untitled) / with headers
text/plain 986b
On 2011.12.8 5:37 PM, Kent Fredric via RT wrote: Show quoted text
> On further attempts it appears I *can* chdir into it, just its, well, weird.
It's possible the problem is in the Perl/Cygwin chdir bindings. Either way, if chdir $dir_with_newline doesn't work in Perl then that's all File::chdir cares about. Show quoted text
> Kent@Katipo /tmp > mkdir "$( /bin/echo.exe -ne "bog\nstandard" )" > > Kent@Katipo /tmp > cd "$( /bin/echo.exe -ne "bog\nstandard" )" > > Kent@Katipo /tmp/bogstandard > $ echo "$PWD" > /tmp/bog > standard > > Kent@Katipo /tmp/bogstandard > $ find $PWD > find: `/tmp/bog': No such file or directory > find: `standard': No such file or directory
That makes some sense, there's whitespace in $PWD. You'd have the same problem if PWD contains a space. You asked it to search "/tmp/bog" and "standard". -- 191. Our Humvees cannot be assembled into a giant battle-robot. -- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army http://skippyslist.com/list/

Ok then. Seems perl bindings *do* work properly here too.

use 5.14.1;
use strict;
use warnings;

mkdir("/tmp/bog\nstandard") or die "Can't mkdir with \\n";
chdir("/tmp/bog\nstandard") or die "Can't chdir to dir with \\n";
system("ls -la .");
system("find \"\$PWD\"");
rmdir("/tmp/bog\nstandard");

 

$ perl ex.pl
total 40
drwxr-xr-x+ 1 Kent None 0 Dec 15 22:39 .
drwxrwxrwt+ 1 Kent root 0 Dec 15 22:39 ..
/tmp/bog?standard

 

Anything else you can ask me for please do, I'm confused as hell now =)

 

Ok, I started re-hashing this and re-thinking it. Obviously the underlying infrastructure can handle it, just something is going wrong somewhere.

 

 use Test::More;
+use Test::Fatal;

    local $CWD = $Test_Dir;
+ is exception {
+        defined $CWD;
+    }, undef , "Evaluating CWD doesn't panic";
 

So on my platform, for some reason, it fails when $CWD has a "\n" in it.

However, if I silence the fatal exception inside the  {   } area,

    exception {
            is $CWD, abs_path;
    };
 

tests 2 and 3 pass successfully.

I haven't looked at how $CWD works under the hood yet, but I think this leads me to one of 2 conclusions

1. Its actually working, just for some reason falsely excepting when $CWD is evaluated, thinking it cant work when it has.

2. directory changes don't happen until $CWD is evaluated, not when $CWD is assigned as I first assumed.

Hopefully this is more constructive.

On 2012-01-03 05:24:56, KENTNL wrote:
Show quoted text
> Ok, I started re-hashing this and re-thinking it. Obviously the
> underlying
> infrastructure can handle it, just something is going wrong somewhere.
>
> use Test::More;
> +use Test::Fatal;
>
> local $CWD = $Test_Dir;
> + is exception {
> + defined $CWD;
> + }, undef , "Evaluating CWD doesn't panic";
>
> So on my platform, for some reason, it fails when $CWD has a "\n" in
> it.
>
> However, if I silence the fatal exception inside the { } area,
>
> exception {
> is $CWD, abs_path;
> };
>
> tests 2 and 3 pass successfully.
>
> I haven't looked at how $CWD works under the hood yet, but I think
> this leads
> me to one of 2 conclusions
>
> 1. Its actually working, just for some reason falsely excepting when
> $CWD is
> evaluated, thinking it cant work when it has.
>
> 2. directory changes don't happen until $CWD is evaluated, not when
> $CWD is
> assigned as I first assumed.
>
> Hopefully this is more constructive.

Ah!. So the CWD *does* happen on STORE, and the error ONLY happens on FETCH. Curious.

And the error line is this one:   my ( $cwd ) = Cwd::abs_path =~ /(.*)/s;

So further testing yeilds:

 is exception {
        Cwd::abs_path;
    }, undef, 'Cwd::abs_path is broken';
 

Which as I suspect, fails.

So I guess its time to punt this problem over to File::Spec team.

 

https://rt.cpan.org/Ticket/Display.html?id=73679 # The bug on File::Spec if you want to track it.

Turns out it looks like a problem in Cwd::fast_abs_path , which Cwd::abs_path resolves to on some platforms ( ie: Cygwin ).

You can temporarily get around this by calling Cwd::_perl_abs_path instead which doesn't appear to have the same flaw, but probably has a larger speed penalty.

Subject: Re: [rt.cpan.org #72924] Fails t/newline.t on Cygwin
Date: Mon, 2 Jan 2012 21:07:08 -0500
To: bug-File-chdir [...] rt.cpan.org
From: David Golden <dagolden [...] cpan.org>
Download (untitled) / with headers
text/plain 288b
On Mon, Jan 2, 2012 at 12:47 PM, Kent Fredric via RT <bug-File-chdir@rt.cpan.org> wrote: Show quoted text
> Turns out it looks like a problem in Cwd::fast_abs_path , which Cwd::abs_path > resolves to on some platforms ( ie: Cygwin ).
Thanks, Kent, for doing such great sleuthing on this issue. -- David


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.