From 59c415171c8ee3c6872ce647955bd0fabb241500 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Sun, 14 Apr 2019 07:23:33 +0300 Subject: [PATCH] Prefer compilers including the version number This should hopefully fix #4433, by finding the Haddock executable even though the copy without a version suffix is unavailable. --- src/Stack/Setup.hs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/Stack/Setup.hs b/src/Stack/Setup.hs index ef541d5793..33964226a7 100644 --- a/src/Stack/Setup.hs +++ b/src/Stack/Setup.hs @@ -698,11 +698,21 @@ ensureSandboxedCompiler sopts getSetupInfo' = do ensureGhcjsBooted cv (soptsInstallIfMissing sopts) (soptsGHCJSBootOpts sopts) _ -> pure () - let name = - case wc of - Ghc -> "ghc" - Ghcjs -> "ghcjs" - withProcessContext menv $ findExecutable name >>= either throwIO parseAbsFile + let names = + case wanted of + WCGhc version -> ["ghc-" ++ versionString version, "ghc"] + WCGhcGit{} -> ["ghc"] + WCGhcjs{} -> ["ghcjs"] + loop [] = do + logError $ "Looked for sandboxed compiler named one of: " <> displayShow names + logError $ "Could not find it on the paths " <> displayShow (edBins paths) + throwString "Could not find sandboxed compiler" + loop (x:xs) = do + res <- findExecutable x + case res of + Left _ -> loop xs + Right y -> parseAbsFile y + withProcessContext menv $ loop names when (soptsSanityCheck sopts) $ sanityCheck compiler cp <- pathsFromCompiler wc compilerBuild isSandboxed compiler