<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">From 0a4d1779402e8824dd675302ad6a1914ea6ccf23 Mon Sep 17 00:00:00 2001
From: Tony Cook &lt;tony@develop-help.com&gt;
Date: Tue, 26 Mar 2019 14:23:53 +1100
Subject: [PATCH] (perl #133951) fallback to the built-in getcwd if we can
--- dist/PathTools/Cwd.pm
+++ dist/PathTools/Cwd.pm
@@ -659,6 +659,10 @@ if (exists $METHOD_MAP{$^O}) {
   }
 }
 
+# built-in from 5.30
+*getcwd = \&amp;Internals::getcwd
+  if !defined &amp;getcwd &amp;&amp; defined &amp;Internals::getcwd;
+
 # In case the XS version doesn't load.
 *abs_path = \&amp;_perl_abs_path unless defined &amp;abs_path;
 *getcwd = \&amp;_perl_getcwd unless defined &amp;getcwd;
--- dist/PathTools/t/cwd.t
+++ 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-&gt;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;
</pre></body></html>