diff --git a/cabal-install/src/Distribution/Client/ProjectPlanning.hs b/cabal-install/src/Distribution/Client/ProjectPlanning.hs index c04bca730d7..752a16aad25 100644 --- a/cabal-install/src/Distribution/Client/ProjectPlanning.hs +++ b/cabal-install/src/Distribution/Client/ProjectPlanning.hs @@ -2327,6 +2327,7 @@ elaborateInstallPlan ] <> perPkgOptionMapMappend pkgid packageConfigProgramArgs elabProgramPathExtra = perPkgOptionNubList pkgid packageConfigProgramPathExtra + elabConfiguredPrograms = configuredPrograms compilerprogdb elabConfigureScriptArgs = perPkgOptionList pkgid packageConfigConfigureArgs elabExtraLibDirs = perPkgOptionList pkgid packageConfigExtraLibDirs elabExtraLibDirsStatic = perPkgOptionList pkgid packageConfigExtraLibDirsStatic diff --git a/cabal-install/src/Distribution/Client/ProjectPlanning/Types.hs b/cabal-install/src/Distribution/Client/ProjectPlanning/Types.hs index 7ee5cb52f41..e7f864968b0 100644 --- a/cabal-install/src/Distribution/Client/ProjectPlanning/Types.hs +++ b/cabal-install/src/Distribution/Client/ProjectPlanning/Types.hs @@ -274,6 +274,7 @@ data ElaboratedConfiguredPackage = ElaboratedConfiguredPackage , elabProgramPaths :: Map String FilePath , elabProgramArgs :: Map String [String] , elabProgramPathExtra :: [FilePath] + , elabConfiguredPrograms :: [ConfiguredProgram] , elabConfigureScriptArgs :: [String] , elabExtraLibDirs :: [FilePath] , elabExtraLibDirsStatic :: [FilePath] diff --git a/cabal-testsuite/PackageTests/PathRecomp/PathRecomp.cabal b/cabal-testsuite/PackageTests/PathRecomp/PathRecomp.cabal new file mode 100644 index 00000000000..9b754fadc8c --- /dev/null +++ b/cabal-testsuite/PackageTests/PathRecomp/PathRecomp.cabal @@ -0,0 +1,13 @@ +name: PathRecomp +version: 0.1.0.0 +license: BSD3 +author: Test Author +maintainer: test@example.com +build-type: Simple +cabal-version: >=1.10 + +library + exposed-modules: Lib + hs-source-dirs: src + build-depends: base + default-language: Haskell2010 diff --git a/cabal-testsuite/PackageTests/PathRecomp/Setup.hs b/cabal-testsuite/PackageTests/PathRecomp/Setup.hs new file mode 100644 index 00000000000..200a2e51d0b --- /dev/null +++ b/cabal-testsuite/PackageTests/PathRecomp/Setup.hs @@ -0,0 +1,3 @@ +import Distribution.Simple +main = defaultMain + diff --git a/cabal-testsuite/PackageTests/PathRecomp/cabal.test.hs b/cabal-testsuite/PackageTests/PathRecomp/cabal.test.hs new file mode 100644 index 00000000000..5b321205d87 --- /dev/null +++ b/cabal-testsuite/PackageTests/PathRecomp/cabal.test.hs @@ -0,0 +1,21 @@ +import Test.Cabal.Prelude +import qualified Data.Map as Map +import qualified Control.Monad.IO.Class as IO +import System.Environment (getEnvironment) + +main = cabalTest $ recordMode DoNotRecord $ do + -- First run cabal repl with the normal PATH + env <- IO.liftIO getEnvironment + let originalPath = maybe "" id (lookup "PATH" env) + + -- Run repl with original PATH + cabalWithStdin "repl" ["lib:PathRecomp"] "" >>= assertOutputContains "module loaded" + + -- Now modify the PATH by prefixing with a dummy directory + -- This simulates a user modifying their PATH between cabal commands + let modifiedPath = "/dummy/path:" ++ originalPath + withEnv [("PATH", Just modifiedPath)] $ do + -- Run repl with modified PATH - this should still work + r <- cabalWithStdin "repl" ["lib:PathRecomp"] "(Prelude.fmap . Prelude.fmap) (\"/dummy/path\" `Data.List.isInfixOf`) (System.Environment.lookupEnv \"PATH\")" + assertOutputContains "module loaded" r + assertOutputContains "Just True" r diff --git a/cabal-testsuite/PackageTests/PathRecomp/src/Lib.hs b/cabal-testsuite/PackageTests/PathRecomp/src/Lib.hs new file mode 100644 index 00000000000..51e415dfda0 --- /dev/null +++ b/cabal-testsuite/PackageTests/PathRecomp/src/Lib.hs @@ -0,0 +1,7 @@ +module Lib + ( someFunc + ) where + +someFunc :: IO () +someFunc = putStrLn "someFunc" + diff --git a/changelog.d/pr-10817 b/changelog.d/pr-10817 new file mode 100644 index 00000000000..0473cffcab8 --- /dev/null +++ b/changelog.d/pr-10817 @@ -0,0 +1,15 @@ +synopsis: Fix PATH changes not triggering REPL reconfiguration +packages: cabal-install +prs: #10817 +issues: #2015 + +When modifying your PATH environment variable between Cabal commands, REPL +sessions will now correctly use the updated environment. Previously, if you +changed your PATH after initial configuration, Cabal would continue using the +old PATH settings in REPL sessions without warning. + +With this fix, Cabal properly detects PATH changes and reconfigures the REPL +accordingly, ensuring tools and libraries in your current PATH are available. +While this may cause additional rebuilds when PATH changes, it prevents the +confusing errors that could occur when your REPL environment didn't match your +system configuration.