Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix run command environment #9341

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -263,6 +263,7 @@ withTempEnvFile verbosity baseCtx buildCtx buildStatus action = do
action envOverrides
)

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

-- | Get paths to all dependency executables to be included in PATH.
binDirectories
:: DistDirLayout
-> ElaboratedSharedConfig
Expand Down
8 changes: 8 additions & 0 deletions cabal-install/src/Distribution/Client/CmdRun.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import Distribution.Client.ProjectPlanning
)
import Distribution.Client.ProjectPlanning.Types
( dataDirsEnvironmentForPlan
, elabExeDependencyPaths
)
import Distribution.Client.ScriptUtils
( AcceptNoTargets (..)
Expand Down Expand Up @@ -275,6 +276,12 @@ runAction flags@NixStyleFlags{..} targetAndArgs globalFlags =
dieWithException verbosity $
MultipleMatchingExecutables exeName (fmap (\p -> " - in package " ++ prettyShow (elabUnitId p)) elabPkgs)

-- Some dependencies may have executables. Let's put those on the PATH.
let extraPaths = elabExeDependencyPaths pkg
info verbosity . unlines $
"Including the following directories in PATH:"
: extraPaths

let defaultExePath =
binDirectoryFor
(distDirLayout baseCtx)
Expand All @@ -300,6 +307,7 @@ runAction flags@NixStyleFlags{..} targetAndArgs globalFlags =
dataDirsEnvironmentForPlan
(distDirLayout baseCtx)
elaboratedPlan
, progInvokePathEnv = extraPaths
}
where
(targetStr, args) = splitAt 1 targetAndArgs
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.

}
Loading