diff --git a/cpan/CPAN/lib/CPAN/FirstTime.pm b/cpan/CPAN/lib/CPAN/FirstTime.pm
index af4a6d7..162639f 100644
--- a/cpan/CPAN/lib/CPAN/FirstTime.pm
+++ b/cpan/CPAN/lib/CPAN/FirstTime.pm
@@ -1593,6 +1593,23 @@ sub _init_external_progs {
               if ( $disabling && $showed_make_warning ) {
                 next;
               }
+
+            # Let's not store full paths to programs in MSYS2 because
+            # paths change across shells. For example let's not use 32-bit
+            # programs in the 64-bit shell.
+
+            if ($^O eq 'MSWin32') {
+                $CPAN::Config->{$progname} = $CPAN::Config->{$progname}
+                    || $Config::Config{$progname}
+                        || $progname;
+                if ($CPAN::Config->{$progname} eq 'make') {
+                    # (msys) make doesn't like the cmd.exe-friendly makefiles that are
+                    # created when installing modules, so stick to mingw32-make.
+                    $CPAN::Config->{$progname} = 'mingw32-make';
+                }
+                next;
+            }
+
               else {
                 _beg_for_make() unless $showed_make_warning++;
                 undef $CPAN::Config->{$progname};
-- 
2.31.1.windows.1

