From 87f2ddd25c4d688335a70194e0385610255668e1 Mon Sep 17 00:00:00 2001 From: Yvan Sraka Date: Fri, 3 Nov 2023 12:09:29 +0100 Subject: [PATCH] [cabal-7825] Add `$CABAL` env variable for external commands This is a follow-up of #9063 --- Cabal/src/Distribution/Simple/Command.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Cabal/src/Distribution/Simple/Command.hs b/Cabal/src/Distribution/Simple/Command.hs index dc2be1a698b..ae191ccc30a 100644 --- a/Cabal/src/Distribution/Simple/Command.hs +++ b/Cabal/src/Distribution/Simple/Command.hs @@ -94,6 +94,7 @@ import Distribution.ReadE import Distribution.Simple.Utils import System.Directory (findExecutable) import System.Process (callProcess) +import System.Environment (getExecutablePath, setEnv) data CommandUI flags = CommandUI { commandName :: String @@ -651,7 +652,10 @@ commandsRun globalCommand commands args = _ -> do mCommand <- findExecutable $ "cabal-" <> name case mCommand of - Just exec -> callExternal flags exec cmdArgs + Just exec -> do + execPath <- getExecutablePath + void $ setEnv "CABAL" execPath + callExternal flags exec cmdArgs Nothing -> pure $ CommandReadyToGo (flags, badCommand name) [] -> pure $ CommandReadyToGo (flags, noCommand) where