Skip to content

Commit f06195d

Browse files
xsebekMikolaj
authored andcommitted
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 46df8ba commit f06195d

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ withTempEnvFile verbosity baseCtx buildCtx buildStatus action = do
268268
action envOverrides
269269
)
270270

271+
-- | Get paths to all dependency executables to be included in PATH.
271272
pathAdditions :: ProjectBaseContext -> ProjectBuildContext -> [FilePath]
272273
pathAdditions ProjectBaseContext{..} ProjectBuildContext{..} =
273274
paths ++ cabalConfigPaths
@@ -281,6 +282,7 @@ pathAdditions ProjectBaseContext{..} ProjectBuildContext{..} =
281282
S.toList $
282283
binDirectories distDirLayout elaboratedShared elaboratedPlanToExecute
283284

285+
-- | Get paths to all dependency executables to be included in PATH.
284286
binDirectories
285287
:: DistDirLayout
286288
-> ElaboratedSharedConfig

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import Distribution.Client.ProjectPlanning
6060
)
6161
import Distribution.Client.ProjectPlanning.Types
6262
( dataDirsEnvironmentForPlan
63+
, elabExeDependencyPaths
6364
)
6465
import Distribution.Client.ScriptUtils
6566
( AcceptNoTargets (..)
@@ -302,11 +303,13 @@ runAction flags@NixStyleFlags{..} targetAndArgs globalFlags =
302303
|| buildSettingOnlyDownload (buildSettings baseCtx)
303304

304305
let extraPath =
305-
fromNubList
306-
. projectConfigProgPathExtra
307-
. projectConfigShared
308-
. projectConfig
309-
$ baseCtx
306+
elabExeDependencyPaths pkg
307+
++ ( fromNubList
308+
. projectConfigProgPathExtra
309+
. projectConfigShared
310+
. projectConfig
311+
$ baseCtx
312+
)
310313

311314
logExtraProgramSearchPath verbosity extraPath
312315

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)