Skip to content

Commit

Permalink
Honor build-tool-depends in CmdRun
Browse files Browse the repository at this point in the history
Similarly to CmdExec and CmdTest, get paths to all dependency binaries
and add those to PATH. Unlike CmdExec, add just the explicitly required
paths.
  • Loading branch information
xsebek authored and jasagredo committed Jan 13, 2024
1 parent f0477d0 commit b0a2344
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
2 changes: 2 additions & 0 deletions cabal-install/src/Distribution/Client/CmdExec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
13 changes: 8 additions & 5 deletions cabal-install/src/Distribution/Client/CmdRun.hs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import Distribution.Client.ProjectPlanning
)
import Distribution.Client.ProjectPlanning.Types
( dataDirsEnvironmentForPlan
, elabExeDependencyPaths
)
import Distribution.Client.ScriptUtils
( AcceptNoTargets (..)
Expand Down Expand Up @@ -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

Expand Down
11 changes: 11 additions & 0 deletions changelog.d/pr-9341
Original file line number Diff line number Diff line change
@@ -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.

}

0 comments on commit b0a2344

Please sign in to comment.