Skip to content

Commit 2bf27ac

Browse files
committed
Monitor imported cabal.project files as well
Fixes #10255
1 parent 6e60fe8 commit 2bf27ac

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
@@ -853,14 +853,21 @@ readProjectFileSkeletonGen
853853
exists <- liftIO $ doesFileExist extensionFile
854854
if exists
855855
then do
856-
monitorFiles [monitorFileHashed extensionFile]
857856
pcs <- liftIO $ parseConfig extensionFile
858-
monitorFiles $ map monitorFileHashed (projectConfigPathRoot <$> projectSkeletonImports pcs)
857+
858+
-- we need to monitor the main project file as well as all (possibly recursive) imports
859+
let allProjectFiles = map makeAbsolute . nub . concat $ projectConfigPathAll <$> projectSkeletonImports pcs
860+
monitorFiles $ map monitorFileHashed allProjectFiles
861+
859862
return pcs
860863
else do
861864
monitorFiles [monitorNonExistentFile extensionFile]
862865
return mempty
863866
where
867+
-- do we prefer absolute paths for cache monitoring?
868+
makeAbsolute f
869+
| isAbsolute f = f
870+
| otherwise = distProjectRootDirectory dir </> f
864871
extensionFile = (distProjectFile dir) extensionName
865872

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

0 commit comments

Comments
 (0)