diff --git a/cabal-install/src/Distribution/Client/CmdExec.hs b/cabal-install/src/Distribution/Client/CmdExec.hs index 3a3dd306d8a..fd42e47f222 100644 --- a/cabal-install/src/Distribution/Client/CmdExec.hs +++ b/cabal-install/src/Distribution/Client/CmdExec.hs @@ -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 $ @@ -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 diff --git a/cabal-install/src/Distribution/Client/CmdRun.hs b/cabal-install/src/Distribution/Client/CmdRun.hs index 2ad1b992369..170d74816c7 100644 --- a/cabal-install/src/Distribution/Client/CmdRun.hs +++ b/cabal-install/src/Distribution/Client/CmdRun.hs @@ -56,6 +56,7 @@ import Distribution.Client.ProjectPlanning ) import Distribution.Client.ProjectPlanning.Types ( dataDirsEnvironmentForPlan + , elabExeDependencyPaths ) import Distribution.Client.ScriptUtils ( AcceptNoTargets (..) @@ -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) @@ -300,6 +307,7 @@ runAction flags@NixStyleFlags{..} targetAndArgs globalFlags = dataDirsEnvironmentForPlan (distDirLayout baseCtx) elaboratedPlan + , progInvokePathEnv = extraPaths } where (targetStr, args) = splitAt 1 targetAndArgs 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