diff --git a/cabal-install/src/Distribution/Client/CmdExec.hs b/cabal-install/src/Distribution/Client/CmdExec.hs index 3a3dd306d8a..f463c3881e3 100644 --- a/cabal-install/src/Distribution/Client/CmdExec.hs +++ b/cabal-install/src/Distribution/Client/CmdExec.hs @@ -12,6 +12,8 @@ module Distribution.Client.CmdExec ( execAction , execCommand + -- Utility function exposed for run command + , pathAdditions ) where import Distribution.Client.DistDirLayout @@ -263,6 +265,12 @@ withTempEnvFile verbosity baseCtx buildCtx buildStatus action = do action envOverrides ) +-- | Get paths to all dependency executables to be included in PATH. +-- +-- The filepaths need to be passed to the executable for example +-- by 'modifyProgramSearchPath' if you are using 'ProgramDb' +-- or more directly by passing them to 'progInvokePathEnv' +-- if you are using 'ProgramInvocation'. pathAdditions :: Verbosity -> ProjectBaseContext -> ProjectBuildContext -> IO [FilePath] pathAdditions verbosity ProjectBaseContext{..} ProjectBuildContext{..} = do info verbosity . unlines $ diff --git a/cabal-install/src/Distribution/Client/CmdRun.hs b/cabal-install/src/Distribution/Client/CmdRun.hs index 2ad1b992369..0c0a92da50a 100644 --- a/cabal-install/src/Distribution/Client/CmdRun.hs +++ b/cabal-install/src/Distribution/Client/CmdRun.hs @@ -35,6 +35,7 @@ import Distribution.Client.CmdErrorMessages , targetSelectorFilter , targetSelectorPluralPkgs ) +import Distribution.Client.CmdExec (pathAdditions) import Distribution.Client.Errors import Distribution.Client.GlobalFlags ( defaultGlobalFlags @@ -230,6 +231,9 @@ runAction flags@NixStyleFlags{..} targetAndArgs globalFlags = elaboratedPlan return (elaboratedPlan', targets) + -- Some dependencies may have executables. Let's put those on the PATH. + extraPaths <- pathAdditions verbosity baseCtx buildCtx + (selectedUnitId, selectedComponent) <- -- Slight duplication with 'runProjectPreBuildPhase'. singleExeOrElse @@ -300,6 +304,7 @@ runAction flags@NixStyleFlags{..} targetAndArgs globalFlags = dataDirsEnvironmentForPlan (distDirLayout baseCtx) elaboratedPlan + , progInvokePathEnv = extraPaths } where (targetStr, args) = splitAt 1 targetAndArgs