From 286f6422c10f35dbb922540e185df74410fa5af4 Mon Sep 17 00:00:00 2001 From: Mike Pilgrem Date: Fri, 10 Jul 2026 22:51:48 +0100 Subject: [PATCH] Re #6944 Warn if `--force-dirty` redundant --- ChangeLog.md | 2 ++ src/Stack/Build.hs | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 5807b6f913..746527c940 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -27,6 +27,8 @@ Behavior changes: * With Nix integration, Stack uses `nix-instantiate` before `nix-shell`, enabling Stack to catch and report when the Nix expression cannot be evaluated by Nix. The `nix-instantiate-options` option is added, accordingly. +* Stack's `build` command now warns if `--force-dirty` is specified but no + local packages will be built. Other enhancements: diff --git a/src/Stack/Build.hs b/src/Stack/Build.hs index 79daad36c7..a3d7a7cfd5 100644 --- a/src/Stack/Build.hs +++ b/src/Stack/Build.hs @@ -199,9 +199,20 @@ build msetLocalFiles = do boptsCli.initialBuildSteps allowLocals <- view $ configL . to (.allowLocals) - unless allowLocals $ case justLocals plan of - [] -> pure () - localsIdents -> throwM $ LocalPackagesPresent localsIdents + case justLocals plan of + [] -> when bopts.forceDirty $ prettyWarn $ + fillSep + [ style Shell "--force-dirty" + , flow "is specified but no local packages will be built." + ] + <> blankLine + <> flow "If your aim is that Stack rebuilds an installed package (one \ + \registered in the relevant package database) that Stack deems \ + \immutable, first unregister it from the database by commanding:" + <> blankLine + <> style Shell "stack exec -- ghc-pkg unregister --force " + localsIdents -> unless allowLocals $ + throwM $ LocalPackagesPresent localsIdents checkCabalVersion haddockCompsSupported <- warnAboutHaddockComps bopts