From 34752db1975bf1b2fcaaab5576b5ebc481c67e2b Mon Sep 17 00:00:00 2001 From: Max Ulidtko Date: Fri, 10 Jul 2026 18:25:37 +0200 Subject: [PATCH] Re #1476 Emit a Note-level hint when caching with --force-dirty --- src/Stack/Build/ExecutePackage.hs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Stack/Build/ExecutePackage.hs b/src/Stack/Build/ExecutePackage.hs index 36f3207c89..717aa91388 100644 --- a/src/Stack/Build/ExecutePackage.hs +++ b/src/Stack/Build/ExecutePackage.hs @@ -128,7 +128,7 @@ import Stack.Types.ComponentUtils ( StackUnqualCompName, toCabalName, unqualCompToString , unqualCompToText ) -import Stack.Types.Config ( Config (..), HasConfig (..) ) +import Stack.Types.Config ( Config (..), HasConfig (..), buildOptsL ) import Stack.Types.ConfigureOpts ( BaseConfigOpts (..), ConfigureOpts (..) ) import Stack.Types.Curator ( Curator (..) ) @@ -481,6 +481,7 @@ singleBuild case mprecompiled of Just precompiled -> copyPreCompiled isCInstTask ee task pkgId precompiled + <* warnImmutableCacheWithForceDirty Nothing -> do curator <- view $ buildConfigL . to (.curator) realConfigAndBuild @@ -512,6 +513,19 @@ singleBuild enableBenchmarks = buildingFinals && componentEnableBenchmarks ck (taskComponents task) + -- Give a hint for surprisingly cached builds, https://github.com/commercialhaskell/stack/issues/1476 + warnImmutableCacheWithForceDirty = do + forceDirtyFlagGiven <- view $ buildOptsL . to (.forceDirty) + targetsCLI <- view $ envConfigL . to (.buildOptsCLI.targetsCLI) + when (forceDirtyFlagGiven && fromPackageName (pkgName pkgId) `elem` targetsCLI) $ do + let pkg = fromPackageName (pkgName pkgId) + prettyNote $ + fillSep [flow "Immutable snapshot package", style Current pkg, flow "picked from cached build despite --force-dirty."] + <> blankLine + <> flow "To force removal of cached build, try `stack exec -- ghc-pkg unregister --force " <+> pkg <> "`." + <> blankLine + <> flow "See Stack issue #1476 for more details." + realConfigAndBuild :: forall env a. HasEnvConfig env => ActionContext