Skip to content

Commit cd2a3c4

Browse files
committed
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.
1 parent 9f37325 commit cd2a3c4

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

cabal-install/src/Distribution/Client/CmdExec.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ withTempEnvFile verbosity baseCtx buildCtx buildStatus action = do
263263
action envOverrides
264264
)
265265

266+
-- | Get paths to all dependency executables to be included in PATH and log them.
266267
pathAdditions :: Verbosity -> ProjectBaseContext -> ProjectBuildContext -> IO [FilePath]
267268
pathAdditions verbosity ProjectBaseContext{..} ProjectBuildContext{..} = do
268269
info verbosity . unlines $
@@ -274,6 +275,7 @@ pathAdditions verbosity ProjectBaseContext{..} ProjectBuildContext{..} = do
274275
S.toList $
275276
binDirectories distDirLayout elaboratedShared elaboratedPlanToExecute
276277

278+
-- | Get paths to all dependency executables to be included in PATH.
277279
binDirectories
278280
:: DistDirLayout
279281
-> ElaboratedSharedConfig

cabal-install/src/Distribution/Client/CmdRun.hs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ import Distribution.Client.ProjectPlanning
5555
, binDirectoryFor
5656
)
5757
import Distribution.Client.ProjectPlanning.Types
58-
( dataDirsEnvironmentForPlan
58+
( dataDirsEnvironmentForPlan, elabExeDependencyPaths
5959
)
6060
import Distribution.Client.ScriptUtils
6161
( AcceptNoTargets (..)
@@ -275,6 +275,12 @@ runAction flags@NixStyleFlags{..} targetAndArgs globalFlags =
275275
dieWithException verbosity $
276276
MultipleMatchingExecutables exeName (fmap (\p -> " - in package " ++ prettyShow (elabUnitId p)) elabPkgs)
277277

278+
-- Some dependencies may have executables. Let's put those on the PATH.
279+
let extraPaths = elabExeDependencyPaths pkg
280+
info verbosity . unlines $
281+
"Including the following directories in PATH:"
282+
: extraPaths
283+
278284
let defaultExePath =
279285
binDirectoryFor
280286
(distDirLayout baseCtx)
@@ -300,6 +306,7 @@ runAction flags@NixStyleFlags{..} targetAndArgs globalFlags =
300306
dataDirsEnvironmentForPlan
301307
(distDirLayout baseCtx)
302308
elaboratedPlan
309+
, progInvokePathEnv = extraPaths
303310
}
304311
where
305312
(targetStr, args) = splitAt 1 targetAndArgs

changelog.d/pr-9341

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
synopsis: Fix run command environment
2+
packages: cabal-install
3+
prs: #9341
4+
issues: #8391
5+
6+
description: {
7+
8+
- The Run command will now add binary paths of dependencies
9+
(build-tool-depends) to PATH, just like Exec and Test commands.
10+
11+
}

0 commit comments

Comments
 (0)