diff --git a/cabal-install/src/Distribution/Client/ProjectPlanning.hs b/cabal-install/src/Distribution/Client/ProjectPlanning.hs index f453a1aafbb670a9185b160e72f7fef76793b036..57a60477803f41b50898faa4dc4408328d8d56c5 100644 --- a/cabal-install/src/Distribution/Client/ProjectPlanning.hs +++ b/cabal-install/src/Distribution/Client/ProjectPlanning.hs @@ -2334,6 +2334,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 7ee5cb52f41f68ceee05e48e5f1ed7160c591076..e7f864968b0bebd377d3fdd9b0dc6d72c89c875d 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 0000000000000000000000000000000000000000..9b754fadc8c037ae5794c134168cd682dedff169 --- /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 0000000000000000000000000000000000000000..200a2e51d0b46fa8a38d91b749f59f20eb97a46d --- /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 0000000000000000000000000000000000000000..5b321205d879a41dfe2965c9c23b70d66d0adce6 --- /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 0000000000000000000000000000000000000000..51e415dfda023586363446f146386d43d3048bbf --- /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 0000000000000000000000000000000000000000..4e559b36e15c8822c1718a604475d617f104ba2b --- /dev/null +++ b/changelog.d/pr-10817 @@ -0,0 +1,12 @@ +synopsis: Fix PATH changes not triggering REPL reconfiguration +packages: cabal-install +prs: #10817 +issues: #2015 + +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.