summaryrefslogtreecommitdiff
path: root/hadrian
diff options
context:
space:
mode:
authorSebastian Graf <sebastian.graf@kit.edu>2021-01-22 15:53:06 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-01-27 17:42:21 -0500
commit614cb0690afc8a54104cc95e41b91d68b330b707 (patch)
treeabf00679b77941e60f667c64c61499d30b455dfc /hadrian
parent189efc39e0cf111bcb6d2ad5d474fcd01a706eb8 (diff)
downloadhaskell-614cb0690afc8a54104cc95e41b91d68b330b707.tar.gz
hadrian: Fix `lookupInPath` on Windows (#19249)
By querying the PATH variable explicitly via `getSearchPath`, we can work around the special behavior of `findExecutable` on Windows, where it also searches in System32. Fixes #19249.
Diffstat (limited to 'hadrian')
-rw-r--r--hadrian/src/Hadrian/Oracles/Path.hs12
1 files changed, 7 insertions, 5 deletions
diff --git a/hadrian/src/Hadrian/Oracles/Path.hs b/hadrian/src/Hadrian/Oracles/Path.hs
index ab771a485f..753ae74440 100644
--- a/hadrian/src/Hadrian/Oracles/Path.hs
+++ b/hadrian/src/Hadrian/Oracles/Path.hs
@@ -4,7 +4,6 @@ module Hadrian.Oracles.Path (
) where
import Control.Monad
-import Data.Maybe
import Data.Char
import Data.List.Extra
import Development.Shake
@@ -56,7 +55,10 @@ pathOracle = do
return windowsPath
void $ addOracleCache $ \(LookupInPath name) -> do
- let unpack = fromMaybe . error $ "Cannot find executable " ++ quote name
- path <- unifyPath . unpack <$> liftIO (findExecutable name)
- putLoud $ "| Executable found: " ++ name ++ " => " ++ path
- return path
+ path <- liftIO getSearchPath
+ exes <- liftIO (findExecutablesInDirectories path name)
+ exe <- case exes of
+ [] -> error $ "Cannot find executable " ++ quote name
+ (exe:_) -> pure $ unifyPath exe
+ putLoud $ "| Executable found: " ++ name ++ " => " ++ exe
+ return exe