summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjneira <atreyu.bbb@gmail.com>2020-11-25 21:10:39 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-11-30 19:49:31 -0500
commitb94a65afe1e270245cd5b9fe03d59b726dfba8c4 (patch)
tree85c3d30fe2d7db7374dee6306d8b7a0796b06698
parentb6698d73fa9811795ca37ba0b704aa430c390345 (diff)
downloadhaskell-b94a65afe1e270245cd5b9fe03d59b726dfba8c4.tar.gz
Include tried paths in findToolDir error
-rw-r--r--compiler/GHC/SysTools/BaseDir.hs14
1 files changed, 8 insertions, 6 deletions
diff --git a/compiler/GHC/SysTools/BaseDir.hs b/compiler/GHC/SysTools/BaseDir.hs
index f47a32e024..ba401de2de 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