Skip to content

Commit 4ddac4f

Browse files
committed
Monitor imported cabal.project files as well
Fixes #10255
1 parent 17be523 commit 4ddac4f

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

cabal-install-solver/src/Distribution/Solver/Types/ProjectConfigPath.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module Distribution.Solver.Types.ProjectConfigPath
66
-- * Project Config Path Manipulation
77
ProjectConfigPath(..)
88
, projectConfigPathRoot
9+
, projectConfigPathAll
910
, nullProjectConfigPath
1011
, consProjectConfigPath
1112
, unconsProjectConfigPath
@@ -217,6 +218,10 @@ docProjectConfigPathFailReason vr pcp
217218
projectConfigPathRoot :: ProjectConfigPath -> FilePath
218219
projectConfigPathRoot (ProjectConfigPath xs) = last xs
219220

221+
-- | Get all paths.
222+
projectConfigPathAll :: ProjectConfigPath -> [FilePath]
223+
projectConfigPathAll (ProjectConfigPath xs) = NE.toList xs
224+
220225
-- | Used by some tests as a dummy "unused" project root.
221226
nullProjectConfigPath :: ProjectConfigPath
222227
nullProjectConfigPath = ProjectConfigPath $ "unused" :| []

cabal-install/src/Distribution/Client/ProjectConfig.hs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -830,14 +830,21 @@ readProjectFileSkeletonGen
830830
exists <- liftIO $ doesFileExist extensionFile
831831
if exists
832832
then do
833-
monitorFiles [monitorFileHashed extensionFile]
834833
pcs <- liftIO $ parseConfig extensionFile
835-
monitorFiles $ map monitorFileHashed (projectConfigPathRoot <$> projectSkeletonImports pcs)
834+
835+
-- we need to monitor the main project file as well as all (possibly recursive) imports
836+
let allProjectFiles = map makeAbsolute . nub . concatMap projectConfigPathAll $ projectSkeletonImports pcs
837+
monitorFiles $ map monitorFileHashed allProjectFiles
838+
836839
return pcs
837840
else do
838841
monitorFiles [monitorNonExistentFile extensionFile]
839842
return mempty
840843
where
844+
-- do we prefer absolute paths for cache monitoring?
845+
makeAbsolute f
846+
| isAbsolute f = f
847+
| otherwise = distProjectRootDirectory dir </> f
841848
extensionFile = (distProjectFile dir) extensionName
842849

843850
-- There are 3 different variants of the project parsing function.

0 commit comments

Comments
 (0)