Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5.28+ fails to build: miniperl can't locate strict #16903

Open
p5pRT opened this issue Mar 23, 2019 · 18 comments

Comments

@p5pRT
Copy link
Collaborator

commented Mar 23, 2019

Migrated from rt.perl.org#133951 (status was 'open')

Searchable as RT133951$

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 23, 2019

From @ikegami

Hi!

I haven't been able to install 5.28 or newer because of a failure in
write_buildcustomize.pl

The following output is from blead @​
39ce401 (the latest at this time). I gave
the same problem with 5.28.0.

$ make
[snip]
./miniperl -Ilib -f write_buildcustomize.pl
Use of uninitialized value $_[0] in join or string at
dist/PathTools/lib/File/Spec/Unix.pm line 87.
Use of uninitialized value $_[0] in join or string at
dist/PathTools/lib/File/Spec/Unix.pm line 87.
Use of uninitialized value $_[0] in join or string at
dist/PathTools/lib/File/Spec/Unix.pm line 87.
Use of uninitialized value $_[0] in join or string at
dist/PathTools/lib/File/Spec/Unix.pm line 87.
Use of uninitialized value $_[0] in join or string at
dist/PathTools/lib/File/Spec/Unix.pm line 87.
Use of uninitialized value $_[0] in join or string at
dist/PathTools/lib/File/Spec/Unix.pm line 87.
Use of uninitialized value $_[0] in join or string at
dist/PathTools/lib/File/Spec/Unix.pm line 87.
Use of uninitialized value $_[0] in join or string at
dist/PathTools/lib/File/Spec/Unix.pm line 87.
Use of uninitialized value $_[0] in join or string at
dist/PathTools/lib/File/Spec/Unix.pm line 87.
Use of uninitialized value $_[0] in join or string at
dist/PathTools/lib/File/Spec/Unix.pm line 87.
Use of uninitialized value $_[0] in join or string at
dist/PathTools/lib/File/Spec/Unix.pm line 87.
Use of uninitialized value $_[0] in join or string at
dist/PathTools/lib/File/Spec/Unix.pm line 87.
Use of uninitialized value $_[0] in join or string at
dist/PathTools/lib/File/Spec/Unix.pm line 87.
Use of uninitialized value $_[0] in join or string at
dist/PathTools/lib/File/Spec/Unix.pm line 87.
Use of uninitialized value $_[0] in join or string at
dist/PathTools/lib/File/Spec/Unix.pm line 87.
Use of uninitialized value $_[0] in join or string at
dist/PathTools/lib/File/Spec/Unix.pm line 87.
Use of uninitialized value $_[0] in join or string at
dist/PathTools/lib/File/Spec/Unix.pm line 87.
rm -f pod/perl52910delta.pod
/bin/ln -s perldelta.pod pod/perl52910delta.pod
./miniperl -Ilib autodoc.pl
Can't locate strict.pm in @​INC (you may need to install the strict module)
(@​INC contains​: /cpan/AutoLoader/lib /dist/Carp/lib /dist/PathTools
/dist/PathTools/lib /cpan/ExtUtils-Install/lib /cpan/ExtUtils-MakeMaker/lib
/cpan/ExtUtils-Manifest/lib /cpan/File-Path/lib /ext/re
/dist/Term-ReadLine/lib /dist/Exporter/lib /ext/File-Find/lib
/cpan/Text-Tabs/lib /dist/constant/lib /cpan/version/lib
/cpan/Getopt-Long/lib /lib .) at autodoc.pl line 25.
BEGIN failed--compilation aborted at autodoc.pl line 25.
make​: *** [pod/perlintern.pod] Error 2

$ uname -a
Linux springfield 4.14.67-grsec-grsec+ #4 SMP Thu Sep 6 01​:23​:09 PDT 2018
x86_64 x86_64 x86_64 GNU/Linux

I suspect the cause is this​:

$ ls -ld /home
drwxr-x--x 1320 root root 36864 Mar 21 00​:28 /home

I'm not root. Note the lack of ability to read /home. This has been causing
one of Cwd.pm tests to fail to years now. (I filed a ticket, #109760, but
nothing came of it.) This is a shared host, and the permission of /home are
outside of my control.

- Eric "ikegami" Brine

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 24, 2019

From @jkeenan

On Sat, 23 Mar 2019 22​:45​:52 GMT, ikegami@​adaelis.com wrote​:

Hi!

I haven't been able to install 5.28 or newer because of a failure in
write_buildcustomize.pl

[snip]

I suspect the cause is this​:

$ ls -ld /home
drwxr-x--x 1320 root root 36864 Mar 21 00​:28 /home

I'm not root. Note the lack of ability to read /home. This has been causing
one of Cwd.pm tests to fail to years now. (I filed a ticket, #109760, but
nothing came of it.) This is a shared host, and the permission of /home are
outside of my control.

My (limited) understanding of "shared hosts" suggests that one (other than someone with root privileges) would not be able to install applications *at all* in such an environment.

But your first paragraph above suggests that you *have* been able to install versions of perl earlier than 5.28.0 in this environment. Can you clarify what your past experiences in this environment have been?

Also, do you have recommendations for patches?

Thank you very much.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 24, 2019

The RT System itself - Status changed from 'new' to 'open'

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 24, 2019

From @ikegami

I installed them into my home directory, primarily using perlbrew. The lack
of permissions consistently lead to a single failure in the tests of the
pure-Perl implementation of Cwd (see ticket #109760) which I simply ignored.

But I'm guessing that the pure-Perl version of Cwd is now being used during
the installation process, leading to an inability to install 5.28+

On Sun, Mar 24, 2019, 8​:37 AM James E Keenan via RT <
perlbug-followup@​perl.org> wrote​:

On Sat, 23 Mar 2019 22​:45​:52 GMT, ikegami@​adaelis.com wrote​:

Hi!

I haven't been able to install 5.28 or newer because of a failure in
write_buildcustomize.pl

[snip]

I suspect the cause is this​:

$ ls -ld /home
drwxr-x--x 1320 root root 36864 Mar 21 00​:28 /home

I'm not root. Note the lack of ability to read /home. This has been
causing
one of Cwd.pm tests to fail to years now. (I filed a ticket, #109760, but
nothing came of it.) This is a shared host, and the permission of /home
are
outside of my control.

My (limited) understanding of "shared hosts" suggests that one (other than
someone with root privileges) would not be able to install applications *at
all* in such an environment.

But your first paragraph above suggests that you *have* been able to
install versions of perl earlier than 5.28.0 in this environment. Can you
clarify what your past experiences in this environment have been?

Also, do you have recommendations for patches?

Thank you very much.

--
James E Keenan (jkeenan@​cpan.org)

---
via perlbug​: queue​: perl5 status​: new
https://rt-archive.perl.org/perl5/Ticket/Display.html?id=133951

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 24, 2019

From @ikegami

Confirmed that the call to Cwd​::getcwd() in write_buildcustomize.pl returns
undef, causing the subsequent calls to miniperl to fail.

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 24, 2019

From @xenu

On Sun, 24 Mar 2019 16​:57​:04 -0400
Eric Brine <ikegami@​adaelis.com> wrote​:

On Sun, Mar 24, 2019 at 8​:37 AM James E Keenan via RT <
perlbug-followup@​perl.org> wrote​:

Also, do you have recommendations for patches?

No. _perl_getcwd is fundamentally flawed (and so is _perl_abs_path). It's
not possible to reliably obtain the cwd in Pure Perl without executing an
external program. Cwd​::getcwd should be builtin.

Yeah, I agree. BTW, it's already the case on win32. Win32​::GetCwd() is a
built-in in miniperl.

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 25, 2019

From @khwilliamson

On 3/24/19 3​:26 PM, Tomasz Konojacki wrote​:

On Sun, 24 Mar 2019 16​:57​:04 -0400
Eric Brine <ikegami@​adaelis.com> wrote​:

On Sun, Mar 24, 2019 at 8​:37 AM James E Keenan via RT <
perlbug-followup@​perl.org> wrote​:

Also, do you have recommendations for patches?

No. _perl_getcwd is fundamentally flawed (and so is _perl_abs_path). It's
not possible to reliably obtain the cwd in Pure Perl without executing an
external program. Cwd​::getcwd should be builtin.

Yeah, I agree. BTW, it's already the case on win32. Win32​::GetCwd() is a
built-in in miniperl.

Patches welcome

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 25, 2019

From @tonycoz

On Sun, 24 Mar 2019 16​:59​:45 -0700, me@​xenu.pl wrote​:

On Sun, 24 Mar 2019 16​:57​:04 -0400
Eric Brine <ikegami@​adaelis.com> wrote​:

On Sun, Mar 24, 2019 at 8​:37 AM James E Keenan via RT <
perlbug-followup@​perl.org> wrote​:

Also, do you have recommendations for patches?

No. _perl_getcwd is fundamentally flawed (and so is _perl_abs_path). It's
not possible to reliably obtain the cwd in Pure Perl without executing an
external program. Cwd​::getcwd should be builtin.

Yeah, I agree. BTW, it's already the case on win32. Win32​::GetCwd() is a
built-in in miniperl.

I'm looking at this.

write_buildcustomize.pl is problem here too - it shouldn't succeed if it's going to write out garbage.

Tony

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 26, 2019

From rich@hyphen-dash-hyphen.info

On Sun, Mar 24, 2019 at 7​:12 PM Eric Brine <ikegami@​adaelis.com> wrote​:

Confirmed that the call to Cwd​::getcwd() in write_buildcustomize.pl returns undef, causing the subsequent calls to miniperl to fail.

Same problem in https://rt.perl.org/Public/Bug/Display.html?id=133787.
Sticking plaster fix to write_buildcustomize.pl seems to be​:

-my $cwd = Cwd​::getcwd();
+my $cwd = Cwd​::getcwd() || Cwd​::cwd();

But (1) a bodge fix is all that is (2) the same issue might be
involved in the as-yet unresolved remaining problems in RT133787 - and
so later on in your build process too (3) likely other problems
downstream when not running as root.

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 26, 2019

From @tonycoz

On Mon, 25 Mar 2019 17​:17​:12 -0700, rich@​hyphen-dash-hyphen.info wrote​:

On Sun, Mar 24, 2019 at 7​:12 PM Eric Brine <ikegami@​adaelis.com>
wrote​:

Confirmed that the call to Cwd​::getcwd() in write_buildcustomize.pl
returns undef, causing the subsequent calls to miniperl to fail.

Same problem in https://rt.perl.org/Public/Bug/Display.html?id=133787.
Sticking plaster fix to write_buildcustomize.pl seems to be​:

-my $cwd = Cwd​::getcwd();
+my $cwd = Cwd​::getcwd() || Cwd​::cwd();

But (1) a bodge fix is all that is (2) the same issue might be
involved in the as-yet unresolved remaining problems in RT133787 - and
so later on in your build process too (3) likely other problems
downstream when not running as root.

Maybe the attached.

Right now the built-in getcwd() is Internals​::getcwd(), which isn't the best namespace to put it in, but I'm not sure where else it should go.

Tony

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 26, 2019

From @tonycoz

cwd-unreadable-dir.patch
From 21626e64ef929675e95a44df0662b5d778b5c6e9 Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Mon, 25 Mar 2019 16:11:16 +1100
Subject: (perl #133951) don't write an invalid lib/buildcustomize.pl

Cwd under miniperl (at this point) can't determine the current
directory if some ancestor directory isn't readable.

So Cwd::getcwd() would return undef, and write_buildcustomize.pl
would write out a list of paths relative to / rather than to the cwd.
---
 write_buildcustomize.pl | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/write_buildcustomize.pl b/write_buildcustomize.pl
index e82f931bae..862b09fab8 100644
--- a/write_buildcustomize.pl
+++ b/write_buildcustomize.pl
@@ -61,6 +61,9 @@ require Cwd;
 
 my $cwd  = Cwd::getcwd();
 
+defined $cwd
+  or die "$0: Can't determine current working directory\n";
+
 # lib must be last, as the toolchain modules write themselves into it
 # as they build, and it's important that @INC order ensures that the partially
 # written files are always masked by the complete versions.
-- 
2.11.0


From 89964055cbd297551d92ba70d7b3fc2b3291296b Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Mon, 25 Mar 2019 16:48:40 +1100
Subject: (perl #133951) add Internals::getcwd

---
 MANIFEST      |  1 +
 t/io/getcwd.t | 22 ++++++++++++++++++++++
 universal.c   | 22 ++++++++++++++++++++++
 3 files changed, 45 insertions(+)
 create mode 100644 t/io/getcwd.t

diff --git a/MANIFEST b/MANIFEST
index feb56580d1..7e447558e6 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -5424,6 +5424,7 @@ t/io/errno.t			See if $! is correctly set
 t/io/errnosig.t			Test case for restoration $! when leaving signal handlers
 t/io/fflush.t			See if auto-flush on fork/exec/system/qx works
 t/io/fs.t			See if directory manipulations work
+t/io/getcwd.t			See if Internals::getcwd is sane
 t/io/inplace.t			See if inplace editing works
 t/io/iofile.t			See if we can load IO::File on demand
 t/io/iprefix.t			See if inplace editing works with prefixes
diff --git a/t/io/getcwd.t b/t/io/getcwd.t
new file mode 100644
index 0000000000..f3ad58bb4c
--- /dev/null
+++ b/t/io/getcwd.t
@@ -0,0 +1,22 @@
+#!./perl -w
+
+BEGIN {
+    chdir 't' if -d 't';
+    require "./test.pl";
+    set_up_inc('../lib');
+}
+
+use Config;
+
+$Config{d_getcwd}
+  or plan skip_all => "no getcwd";
+
+my $cwd = Internals::getcwd();
+ok(!defined $cwd || $cwd ne "",
+   "Internals::getcwd() returned a reasonable result");
+
+if (defined $cwd) {
+    ok(-d $cwd, "check a success result is a directory");
+}
+
+done_testing();
diff --git a/universal.c b/universal.c
index c1b5dd4b14..66eafc5c3d 100644
--- a/universal.c
+++ b/universal.c
@@ -986,6 +986,25 @@ XS(XS_re_regexp_pattern)
     NOT_REACHED; /* NOTREACHED */
 }
 
+#ifdef HAS_GETCWD
+
+XS(XS_Internals_getcwd)
+{
+    dXSARGS;
+    SV *sv = sv_newmortal();
+
+    if (items != 0)
+        croak_xs_usage(cv, "");
+
+    (void)getcwd_sv(sv);
+
+    SvTAINTED_on(sv);
+    PUSHs(sv);
+    XSRETURN(1);
+}
+
+#endif
+
 #include "vutil.h"
 #include "vxs.inc"
 
@@ -1020,6 +1039,9 @@ static const struct xsub_details these_details[] = {
     {"re::regnames", XS_re_regnames, ";$"},
     {"re::regnames_count", XS_re_regnames_count, ""},
     {"re::regexp_pattern", XS_re_regexp_pattern, "$"},
+#ifdef HAS_GETCWD
+    {"Internals::getcwd", XS_Internals_getcwd, ""},
+#endif
 };
 
 STATIC OP*
-- 
2.11.0


From 02be283a45596e481c576a194dd4a3d6e343f76c Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Tue, 26 Mar 2019 14:23:53 +1100
Subject: (perl #133951) fallback to the built-in getcwd if we can

---
 dist/PathTools/Cwd.pm  |  6 +++++-
 dist/PathTools/t/cwd.t | 11 ++++++++++-
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/dist/PathTools/Cwd.pm b/dist/PathTools/Cwd.pm
index ff0d01d95a..ec3ad5ab45 100644
--- a/dist/PathTools/Cwd.pm
+++ b/dist/PathTools/Cwd.pm
@@ -3,7 +3,7 @@ use strict;
 use Exporter;
 
 
-our $VERSION = '3.77';
+our $VERSION = '3.78';
 my $xs_version = $VERSION;
 $VERSION =~ tr/_//d;
 
@@ -659,6 +659,10 @@ if (exists $METHOD_MAP{$^O}) {
   }
 }
 
+# built-in from 5.30
+*getcwd = \&Internals::getcwd
+  if !defined &getcwd && defined &Internals::getcwd;
+
 # In case the XS version doesn't load.
 *abs_path = \&_perl_abs_path unless defined &abs_path;
 *getcwd = \&_perl_getcwd unless defined &getcwd;
diff --git a/dist/PathTools/t/cwd.t b/dist/PathTools/t/cwd.t
index 483b4378d5..c05693880e 100644
--- a/dist/PathTools/t/cwd.t
+++ b/dist/PathTools/t/cwd.t
@@ -10,6 +10,7 @@ chdir 't';
 use Config;
 use File::Spec;
 use File::Path;
+use Errno qw(EACCES);
 
 use lib File::Spec->catdir('t', 'lib');
 use Test::More;
@@ -208,7 +209,15 @@ SKIP: {
 
     like($abs_path,      qr|$want$|i, "Cwd::abs_path produced $abs_path");
     like($fast_abs_path, qr|$want$|i, "Cwd::fast_abs_path produced $fast_abs_path");
-    like($pas,           qr|$want$|i, "Cwd::_perl_abs_path produced $pas") if $EXTRA_ABSPATH_TESTS;
+    if ($EXTRA_ABSPATH_TESTS) {
+        # _perl_abs_path() can fail if some ancestor directory isn't readable
+        if (defined $pas) {
+            like($pas,           qr|$want$|i, "Cwd::_perl_abs_path produced $pas");
+        }
+        else {
+            is($!+0, EACCES, "check we got the expected error on failure");
+        }
+    }
 
     rmtree($test_dirs[0], 0, 0);
     1 while unlink $file;
-- 
2.11.0

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 26, 2019

From @tonycoz

On Mon, 25 Mar 2019 20​:53​:01 -0700, tonyc wrote​:

On Mon, 25 Mar 2019 17​:17​:12 -0700, rich@​hyphen-dash-hyphen.info
wrote​:

On Sun, Mar 24, 2019 at 7​:12 PM Eric Brine <ikegami@​adaelis.com>
wrote​:

Confirmed that the call to Cwd​::getcwd() in write_buildcustomize.pl
returns undef, causing the subsequent calls to miniperl to fail.

Same problem in
https://rt.perl.org/Public/Bug/Display.html?id=133787.
Sticking plaster fix to write_buildcustomize.pl seems to be​:

-my $cwd = Cwd​::getcwd();
+my $cwd = Cwd​::getcwd() || Cwd​::cwd();

But (1) a bodge fix is all that is (2) the same issue might be
involved in the as-yet unresolved remaining problems in RT133787 -
and
so later on in your build process too (3) likely other problems
downstream when not running as root.

Maybe the attached.

Oops, forgot to commit the version bumps.

Tony

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 26, 2019

From @tonycoz

133951-cwd-unreadable.patch
From 21626e64ef929675e95a44df0662b5d778b5c6e9 Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Mon, 25 Mar 2019 16:11:16 +1100
Subject: (perl #133951) don't write an invalid lib/buildcustomize.pl

Cwd under miniperl (at this point) can't determine the current
directory if some ancestor directory isn't readable.

So Cwd::getcwd() would return undef, and write_buildcustomize.pl
would write out a list of paths relative to / rather than to the cwd.
---
 write_buildcustomize.pl | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/write_buildcustomize.pl b/write_buildcustomize.pl
index e82f931bae..862b09fab8 100644
--- a/write_buildcustomize.pl
+++ b/write_buildcustomize.pl
@@ -61,6 +61,9 @@ require Cwd;
 
 my $cwd  = Cwd::getcwd();
 
+defined $cwd
+  or die "$0: Can't determine current working directory\n";
+
 # lib must be last, as the toolchain modules write themselves into it
 # as they build, and it's important that @INC order ensures that the partially
 # written files are always masked by the complete versions.
-- 
2.11.0


From 89964055cbd297551d92ba70d7b3fc2b3291296b Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Mon, 25 Mar 2019 16:48:40 +1100
Subject: (perl #133951) add Internals::getcwd

---
 MANIFEST      |  1 +
 t/io/getcwd.t | 22 ++++++++++++++++++++++
 universal.c   | 22 ++++++++++++++++++++++
 3 files changed, 45 insertions(+)
 create mode 100644 t/io/getcwd.t

diff --git a/MANIFEST b/MANIFEST
index feb56580d1..7e447558e6 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -5424,6 +5424,7 @@ t/io/errno.t			See if $! is correctly set
 t/io/errnosig.t			Test case for restoration $! when leaving signal handlers
 t/io/fflush.t			See if auto-flush on fork/exec/system/qx works
 t/io/fs.t			See if directory manipulations work
+t/io/getcwd.t			See if Internals::getcwd is sane
 t/io/inplace.t			See if inplace editing works
 t/io/iofile.t			See if we can load IO::File on demand
 t/io/iprefix.t			See if inplace editing works with prefixes
diff --git a/t/io/getcwd.t b/t/io/getcwd.t
new file mode 100644
index 0000000000..f3ad58bb4c
--- /dev/null
+++ b/t/io/getcwd.t
@@ -0,0 +1,22 @@
+#!./perl -w
+
+BEGIN {
+    chdir 't' if -d 't';
+    require "./test.pl";
+    set_up_inc('../lib');
+}
+
+use Config;
+
+$Config{d_getcwd}
+  or plan skip_all => "no getcwd";
+
+my $cwd = Internals::getcwd();
+ok(!defined $cwd || $cwd ne "",
+   "Internals::getcwd() returned a reasonable result");
+
+if (defined $cwd) {
+    ok(-d $cwd, "check a success result is a directory");
+}
+
+done_testing();
diff --git a/universal.c b/universal.c
index c1b5dd4b14..66eafc5c3d 100644
--- a/universal.c
+++ b/universal.c
@@ -986,6 +986,25 @@ XS(XS_re_regexp_pattern)
     NOT_REACHED; /* NOTREACHED */
 }
 
+#ifdef HAS_GETCWD
+
+XS(XS_Internals_getcwd)
+{
+    dXSARGS;
+    SV *sv = sv_newmortal();
+
+    if (items != 0)
+        croak_xs_usage(cv, "");
+
+    (void)getcwd_sv(sv);
+
+    SvTAINTED_on(sv);
+    PUSHs(sv);
+    XSRETURN(1);
+}
+
+#endif
+
 #include "vutil.h"
 #include "vxs.inc"
 
@@ -1020,6 +1039,9 @@ static const struct xsub_details these_details[] = {
     {"re::regnames", XS_re_regnames, ";$"},
     {"re::regnames_count", XS_re_regnames_count, ""},
     {"re::regexp_pattern", XS_re_regexp_pattern, "$"},
+#ifdef HAS_GETCWD
+    {"Internals::getcwd", XS_Internals_getcwd, ""},
+#endif
 };
 
 STATIC OP*
-- 
2.11.0


From 70e01a17cce7532b3ce9dc81d976b0fa02fc7529 Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Tue, 26 Mar 2019 14:23:53 +1100
Subject: (perl #133951) fallback to the built-in getcwd if we can

---
 dist/PathTools/Cwd.pm                     |  6 +++++-
 dist/PathTools/lib/File/Spec.pm           |  2 +-
 dist/PathTools/lib/File/Spec/AmigaOS.pm   |  2 +-
 dist/PathTools/lib/File/Spec/Cygwin.pm    |  2 +-
 dist/PathTools/lib/File/Spec/Epoc.pm      |  2 +-
 dist/PathTools/lib/File/Spec/Functions.pm |  2 +-
 dist/PathTools/lib/File/Spec/Mac.pm       |  2 +-
 dist/PathTools/lib/File/Spec/OS2.pm       |  2 +-
 dist/PathTools/lib/File/Spec/Unix.pm      |  2 +-
 dist/PathTools/lib/File/Spec/VMS.pm       |  2 +-
 dist/PathTools/lib/File/Spec/Win32.pm     |  2 +-
 dist/PathTools/t/cwd.t                    | 11 ++++++++++-
 12 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/dist/PathTools/Cwd.pm b/dist/PathTools/Cwd.pm
index ff0d01d95a..ec3ad5ab45 100644
--- a/dist/PathTools/Cwd.pm
+++ b/dist/PathTools/Cwd.pm
@@ -3,7 +3,7 @@ use strict;
 use Exporter;
 
 
-our $VERSION = '3.77';
+our $VERSION = '3.78';
 my $xs_version = $VERSION;
 $VERSION =~ tr/_//d;
 
@@ -659,6 +659,10 @@ if (exists $METHOD_MAP{$^O}) {
   }
 }
 
+# built-in from 5.30
+*getcwd = \&Internals::getcwd
+  if !defined &getcwd && defined &Internals::getcwd;
+
 # In case the XS version doesn't load.
 *abs_path = \&_perl_abs_path unless defined &abs_path;
 *getcwd = \&_perl_getcwd unless defined &getcwd;
diff --git a/dist/PathTools/lib/File/Spec.pm b/dist/PathTools/lib/File/Spec.pm
index 3e203173a6..7fe3272721 100644
--- a/dist/PathTools/lib/File/Spec.pm
+++ b/dist/PathTools/lib/File/Spec.pm
@@ -2,7 +2,7 @@ package File::Spec;
 
 use strict;
 
-our $VERSION = '3.77';
+our $VERSION = '3.78';
 $VERSION =~ tr/_//d;
 
 my %module = (
diff --git a/dist/PathTools/lib/File/Spec/AmigaOS.pm b/dist/PathTools/lib/File/Spec/AmigaOS.pm
index 51210e69a1..2b7d18a85f 100644
--- a/dist/PathTools/lib/File/Spec/AmigaOS.pm
+++ b/dist/PathTools/lib/File/Spec/AmigaOS.pm
@@ -3,7 +3,7 @@ package File::Spec::AmigaOS;
 use strict;
 require File::Spec::Unix;
 
-our $VERSION = '3.77';
+our $VERSION = '3.78';
 $VERSION =~ tr/_//d;
 
 our @ISA = qw(File::Spec::Unix);
diff --git a/dist/PathTools/lib/File/Spec/Cygwin.pm b/dist/PathTools/lib/File/Spec/Cygwin.pm
index de401b613a..d44ced3d63 100644
--- a/dist/PathTools/lib/File/Spec/Cygwin.pm
+++ b/dist/PathTools/lib/File/Spec/Cygwin.pm
@@ -3,7 +3,7 @@ package File::Spec::Cygwin;
 use strict;
 require File::Spec::Unix;
 
-our $VERSION = '3.77';
+our $VERSION = '3.78';
 $VERSION =~ tr/_//d;
 
 our @ISA = qw(File::Spec::Unix);
diff --git a/dist/PathTools/lib/File/Spec/Epoc.pm b/dist/PathTools/lib/File/Spec/Epoc.pm
index 264bbc83b3..b611cd9f64 100644
--- a/dist/PathTools/lib/File/Spec/Epoc.pm
+++ b/dist/PathTools/lib/File/Spec/Epoc.pm
@@ -2,7 +2,7 @@ package File::Spec::Epoc;
 
 use strict;
 
-our $VERSION = '3.77';
+our $VERSION = '3.78';
 $VERSION =~ tr/_//d;
 
 require File::Spec::Unix;
diff --git a/dist/PathTools/lib/File/Spec/Functions.pm b/dist/PathTools/lib/File/Spec/Functions.pm
index 0816bb0c99..3f617bdd36 100644
--- a/dist/PathTools/lib/File/Spec/Functions.pm
+++ b/dist/PathTools/lib/File/Spec/Functions.pm
@@ -3,7 +3,7 @@ package File::Spec::Functions;
 use File::Spec;
 use strict;
 
-our $VERSION = '3.77';
+our $VERSION = '3.78';
 $VERSION =~ tr/_//d;
 
 require Exporter;
diff --git a/dist/PathTools/lib/File/Spec/Mac.pm b/dist/PathTools/lib/File/Spec/Mac.pm
index 42406aa7df..d920d2f5db 100644
--- a/dist/PathTools/lib/File/Spec/Mac.pm
+++ b/dist/PathTools/lib/File/Spec/Mac.pm
@@ -4,7 +4,7 @@ use strict;
 use Cwd ();
 require File::Spec::Unix;
 
-our $VERSION = '3.77';
+our $VERSION = '3.78';
 $VERSION =~ tr/_//d;
 
 our @ISA = qw(File::Spec::Unix);
diff --git a/dist/PathTools/lib/File/Spec/OS2.pm b/dist/PathTools/lib/File/Spec/OS2.pm
index f91ec60c54..603781aa85 100644
--- a/dist/PathTools/lib/File/Spec/OS2.pm
+++ b/dist/PathTools/lib/File/Spec/OS2.pm
@@ -4,7 +4,7 @@ use strict;
 use Cwd ();
 require File::Spec::Unix;
 
-our $VERSION = '3.77';
+our $VERSION = '3.78';
 $VERSION =~ tr/_//d;
 
 our @ISA = qw(File::Spec::Unix);
diff --git a/dist/PathTools/lib/File/Spec/Unix.pm b/dist/PathTools/lib/File/Spec/Unix.pm
index 591846b53e..6749e6047c 100644
--- a/dist/PathTools/lib/File/Spec/Unix.pm
+++ b/dist/PathTools/lib/File/Spec/Unix.pm
@@ -3,7 +3,7 @@ package File::Spec::Unix;
 use strict;
 use Cwd ();
 
-our $VERSION = '3.77';
+our $VERSION = '3.78';
 $VERSION =~ tr/_//d;
 
 =head1 NAME
diff --git a/dist/PathTools/lib/File/Spec/VMS.pm b/dist/PathTools/lib/File/Spec/VMS.pm
index 1e13ac64e7..6c20fb1922 100644
--- a/dist/PathTools/lib/File/Spec/VMS.pm
+++ b/dist/PathTools/lib/File/Spec/VMS.pm
@@ -4,7 +4,7 @@ use strict;
 use Cwd ();
 require File::Spec::Unix;
 
-our $VERSION = '3.77';
+our $VERSION = '3.78';
 $VERSION =~ tr/_//d;
 
 our @ISA = qw(File::Spec::Unix);
diff --git a/dist/PathTools/lib/File/Spec/Win32.pm b/dist/PathTools/lib/File/Spec/Win32.pm
index a4ddca80e7..5934010439 100644
--- a/dist/PathTools/lib/File/Spec/Win32.pm
+++ b/dist/PathTools/lib/File/Spec/Win32.pm
@@ -5,7 +5,7 @@ use strict;
 use Cwd ();
 require File::Spec::Unix;
 
-our $VERSION = '3.77';
+our $VERSION = '3.78';
 $VERSION =~ tr/_//d;
 
 our @ISA = qw(File::Spec::Unix);
diff --git a/dist/PathTools/t/cwd.t b/dist/PathTools/t/cwd.t
index 483b4378d5..c05693880e 100644
--- a/dist/PathTools/t/cwd.t
+++ b/dist/PathTools/t/cwd.t
@@ -10,6 +10,7 @@ chdir 't';
 use Config;
 use File::Spec;
 use File::Path;
+use Errno qw(EACCES);
 
 use lib File::Spec->catdir('t', 'lib');
 use Test::More;
@@ -208,7 +209,15 @@ SKIP: {
 
     like($abs_path,      qr|$want$|i, "Cwd::abs_path produced $abs_path");
     like($fast_abs_path, qr|$want$|i, "Cwd::fast_abs_path produced $fast_abs_path");
-    like($pas,           qr|$want$|i, "Cwd::_perl_abs_path produced $pas") if $EXTRA_ABSPATH_TESTS;
+    if ($EXTRA_ABSPATH_TESTS) {
+        # _perl_abs_path() can fail if some ancestor directory isn't readable
+        if (defined $pas) {
+            like($pas,           qr|$want$|i, "Cwd::_perl_abs_path produced $pas");
+        }
+        else {
+            is($!+0, EACCES, "check we got the expected error on failure");
+        }
+    }
 
     rmtree($test_dirs[0], 0, 0);
     1 while unlink $file;
-- 
2.11.0

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 26, 2019

From @ikegami

On Tue, Mar 26, 2019 at 12​:11 AM Tony Cook via RT <perlbug-followup@​perl.org>
wrote​:

On Mon, 25 Mar 2019 20​:53​:01 -0700, tonyc wrote​:

On Mon, 25 Mar 2019 17​:17​:12 -0700, rich@​hyphen-dash-hyphen.info
wrote​:

On Sun, Mar 24, 2019 at 7​:12 PM Eric Brine <ikegami@​adaelis.com>
wrote​:

Confirmed that the call to Cwd​::getcwd() in write_buildcustomize.pl
returns undef, causing the subsequent calls to miniperl to fail.

Same problem in
https://rt.perl.org/Public/Bug/Display.html?id=133787.
Sticking plaster fix to write_buildcustomize.pl seems to be​:

-my $cwd = Cwd​::getcwd();
+my $cwd = Cwd​::getcwd() || Cwd​::cwd();

But (1) a bodge fix is all that is (2) the same issue might be
involved in the as-yet unresolved remaining problems in RT133787 -
and
so later on in your build process too (3) likely other problems
downstream when not running as root.

Maybe the attached.

Oops, forgot to commit the version bumps.

Tony

Thank you. This patch does resolve the problem; I can successfully build
and test 5.28 when the patch is applied.

Note that while the patch fixes getcwd, but abs_path is still broken. I
shall address this by making _perl_abs_path a direct port of the C
implementation (falling back to the existing version when Internals​::getcwd
isn't available).

  - Eric

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

commented Apr 6, 2019

From rich@hyphen-dash-hyphen.info

On Tue, Mar 26, 2019 at 4​:11 AM Tony Cook via RT
<perlbug-followup@​perl.org> wrote​:

Maybe the attached.

Hi Tony,

This is very useful for #133787 as well. Will it make it into 5.30?

Thanks,
Rich

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

commented Apr 7, 2019

From @xsawyerx

On 4/6/19 11​:55 PM, Richard Leach wrote​:

On Tue, Mar 26, 2019 at 4​:11 AM Tony Cook via RT
<perlbug-followup@​perl.org> wrote​:

Maybe the attached.
Hi Tony,

This is very useful for #133787 as well. Will it make it into 5.30?

I think it should.

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

commented Apr 15, 2019

From @tonycoz

On Sat, 06 Apr 2019 22​:27​:41 -0700, xsawyerx@​gmail.com wrote​:

On 4/6/19 11​:55 PM, Richard Leach wrote​:

On Tue, Mar 26, 2019 at 4​:11 AM Tony Cook via RT
<perlbug-followup@​perl.org> wrote​:

Maybe the attached.
Hi Tony,

This is very useful for #133787 as well. Will it make it into 5.30?

I think it should.

Applied as 05fed87, 15f67d1, 0a4d177.

Tony

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

commented Apr 16, 2019

From rich@hyphen-dash-hyphen.info

On Mon, Apr 15, 2019 at 1​:19 AM Tony Cook via RT
<perlbug-followup@​perl.org> wrote​:

Applied as 05fed87, 15f67d1, 0a4d177.

Tony

---
via perlbug​: queue​: perl5 status​: open
https://rt-archive.perl.org/perl5/Ticket/Display.html?id=133951

Many Thanks!

@p5pRT p5pRT added the Severity Low label Oct 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.