From 99bf11e352f41b1679312c24406d3fb8741a20c5 Mon Sep 17 00:00:00 2001
From: jneira <atreyu.bbb@gmail.com>
Date: Wed, 25 Nov 2020 21:10:39 +0100
Subject: [PATCH] Include tried paths in findToolDir error

---
 compiler/GHC/SysTools/BaseDir.hs | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/compiler/GHC/SysTools/BaseDir.hs b/compiler/GHC/SysTools/BaseDir.hs
index f47a32e02412..ba401de2de52 100644
--- a/compiler/GHC/SysTools/BaseDir.hs
+++ b/compiler/GHC/SysTools/BaseDir.hs
@@ -185,17 +185,19 @@ findToolDir
   :: FilePath -- ^ topdir
   -> IO (Maybe FilePath)
 #if defined(mingw32_HOST_OS) && !defined(USE_INPLACE_MINGW_TOOLCHAIN)
-findToolDir top_dir = go 0 (top_dir </> "..")
+findToolDir top_dir = go 0 (top_dir </> "..") []
   where maxDepth = 3
-        go :: Int -> FilePath -> IO (Maybe FilePath)
-        go k path
+        go :: Int -> FilePath -> [FilePath] -> IO (Maybe FilePath)
+        go k path tried
           | k == maxDepth = throwGhcExceptionIO $
-              InstallationError "could not detect mingw toolchain"
+              InstallationError $ "could not detect mingw toolchain in the following paths: " ++ show tried
           | otherwise = do
-              oneLevel <- doesDirectoryExist (path </> "mingw")
+              let try = path </> "mingw"
+              let tried = tried ++ [try]
+              oneLevel <- doesDirectoryExist try
               if oneLevel
                 then return (Just path)
-                else go (k+1) (path </> "..")
+                else go (k+1) (path </> "..") tried
 #else
 findToolDir _ = return Nothing
 #endif
-- 
GitLab