From eafdd0ee403e1af427340d2c28d85fe4491efa92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ondr=CC=8Cej=20S=CC=8Cebek?= Date: Sat, 21 Oct 2023 22:24:04 +0200 Subject: [PATCH] Honor build-tool-depends in CmdRun Similarly to CmdExec and CmdTest, get paths to all dependency binaries and add those to PATH. Unlike CmdExec, add just the explicitly required paths. --- cabal-install/src/Distribution/Client/CmdExec.hs | 2 ++ cabal-install/src/Distribution/Client/CmdRun.hs | 13 ++++++++----- changelog.d/pr-9341 | 11 +++++++++++ 3 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 changelog.d/pr-9341 diff --git a/cabal-install/src/Distribution/Client/CmdExec.hs b/cabal-install/src/Distribution/Client/CmdExec.hs index 17396d38a98..82fada98463 100644 --- a/cabal-install/src/Distribution/Client/CmdExec.hs +++ b/cabal-install/src/Distribution/Client/CmdExec.hs @@ -268,6 +268,7 @@ withTempEnvFile verbosity baseCtx buildCtx buildStatus action = do action envOverrides ) +-- | Get paths to all dependency executables to be included in PATH. pathAdditions :: ProjectBaseContext -> ProjectBuildContext -> [FilePath] pathAdditions ProjectBaseContext{..} ProjectBuildContext{..} = paths ++ cabalConfigPaths @@ -281,6 +282,7 @@ pathAdditions ProjectBaseContext{..} ProjectBuildContext{..} = S.toList $ binDirectories distDirLayout elaboratedShared elaboratedPlanToExecute +-- | Get paths to all dependency executables to be included in PATH. binDirectories :: DistDirLayout -> ElaboratedSharedConfig diff --git a/cabal-install/src/Distribution/Client/CmdRun.hs b/cabal-install/src/Distribution/Client/CmdRun.hs index ed66b74aff3..b390dacb22e 100644 --- a/cabal-install/src/Distribution/Client/CmdRun.hs +++ b/cabal-install/src/Distribution/Client/CmdRun.hs @@ -60,6 +60,7 @@ import Distribution.Client.ProjectPlanning ) import Distribution.Client.ProjectPlanning.Types ( dataDirsEnvironmentForPlan + , elabExeDependencyPaths ) import Distribution.Client.ScriptUtils ( AcceptNoTargets (..) @@ -302,11 +303,13 @@ runAction flags@NixStyleFlags{..} targetAndArgs globalFlags = || buildSettingOnlyDownload (buildSettings baseCtx) let extraPath = - fromNubList - . projectConfigProgPathExtra - . projectConfigShared - . projectConfig - $ baseCtx + elabExeDependencyPaths pkg + ++ ( fromNubList + . projectConfigProgPathExtra + . projectConfigShared + . projectConfig + $ baseCtx + ) logExtraProgramSearchPath verbosity extraPath diff --git a/changelog.d/pr-9341 b/changelog.d/pr-9341 new file mode 100644 index 00000000000..dc6c65a802d --- /dev/null +++ b/changelog.d/pr-9341 @@ -0,0 +1,11 @@ +synopsis: Fix run command environment +packages: cabal-install +prs: #9341 +issues: #8391 + +description: { + +- The Run command will now add binary paths of dependencies + (build-tool-depends) to PATH, just like Exec and Test commands. + +} \ No newline at end of file