diff --git a/ChangeLog.md b/ChangeLog.md index 802350af6d..4d22828373 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -25,14 +25,16 @@ Other enhancements: Bug fixes: -* `stack test --no-rerun-tests` correctly skips test suites that have - previously been built and run successfully, including for non-Backpack +* `stack test --no-rerun-tests` correctly skips test suites that have + previously been built and run successfully, including for non-Backpack packages built by the per-component planner. -* Stack's per-component build planner correctly handles the cross-package - test/library cycle shape from issue #6905: project package A's library - depending on project package B's library, with B's test suite depending on A, +* Stack's per-component build planner correctly handles the cross-package + test/library cycle shape from issue #6905: project package A's library + depending on project package B's library, with B's test suite depending on A, builds in the right order with the right configure flags. - +* If snapshot locations are cyclic, Stack reports an error rather than going + round in circles. + ## v3.11.1 - 2026-06-13 **Changes since v3.9.3:** diff --git a/cabal.config b/cabal.config index 3157e91a7f..da3964f564 100644 --- a/cabal.config +++ b/cabal.config @@ -146,7 +146,7 @@ constraints: , optparse-applicative ==0.18.1.0 , optparse-simple ==0.1.1.4 , os-string ==2.0.7 - , pantry ==0.11.3 + , pantry ==0.11.4 , parsec ==3.1.18.0 , parser-combinators ==1.3.1 , path ==0.9.6 diff --git a/doc/topics/custom_snapshot.md b/doc/topics/custom_snapshot.md index 1e593104e8..b93d186dd5 100644 --- a/doc/topics/custom_snapshot.md +++ b/doc/topics/custom_snapshot.md @@ -73,10 +73,10 @@ has changed by hashing the contents of the involved files, and using it to identify the snapshot internally. It is often reasonably efficient to modify a custom snapshot, due to Stack sharing snapshot packages whenever possible. -!!! warning "Cyclic snapshot locations" +!!! note "Cyclic snapshot locations" - If snapshot locations form a cycle, Stack will not detect this but will go - round in circles and appear to hang. + If Stack detects that snapshot locations form a cycle, it will report an + error. ### Overriding the compiler diff --git a/doc/topics/snapshot_location.md b/doc/topics/snapshot_location.md index 1b9110c686..c8f67cfa44 100644 --- a/doc/topics/snapshot_location.md +++ b/doc/topics/snapshot_location.md @@ -128,10 +128,10 @@ There are four ways to specify a snapshot location: This allows local file paths and covenience synonyms to be disambiguated. -!!! warning "Cyclic snapshot locations" +!!! note "Cyclic snapshot locations" - If snapshot locations form a cycle, Stack will not detect this but will go - round in circles and appear to hang. + If Stack detects that snapshot locations form a cycle, it will report an + error. ## At the command line diff --git a/package.yaml b/package.yaml index b9d18b3d41..25f9744328 100644 --- a/package.yaml +++ b/package.yaml @@ -105,7 +105,7 @@ dependencies: - neat-interpolation - open-browser - optparse-applicative >= 0.18.1.0 -- pantry >= 0.11.3 +- pantry >= 0.11.4 - path >= 0.9.5 - path-io # In order for Cabal (the tool) to build Stack, it needs to be told of the diff --git a/stack.cabal b/stack.cabal index fa6ab3d39a..5678d0e514 100644 --- a/stack.cabal +++ b/stack.cabal @@ -466,7 +466,7 @@ library , neat-interpolation , open-browser , optparse-applicative >=0.18.1.0 - , pantry >=0.11.3 + , pantry >=0.11.4 , path >=0.9.5 , path-io , persistent >=2.14.0.0 && <2.19 @@ -592,7 +592,7 @@ executable stack , neat-interpolation , open-browser , optparse-applicative >=0.18.1.0 - , pantry >=0.11.3 + , pantry >=0.11.4 , path >=0.9.5 , path-io , persistent >=2.14.0.0 && <2.19 @@ -698,7 +698,7 @@ executable stack-integration-test , open-browser , optparse-applicative >=0.18.1.0 , optparse-generic - , pantry >=0.11.3 + , pantry >=0.11.4 , path >=0.9.5 , path-io , persistent >=2.14.0.0 && <2.19 @@ -818,7 +818,7 @@ test-suite stack-unit-test , neat-interpolation , open-browser , optparse-applicative >=0.18.1.0 - , pantry >=0.11.3 + , pantry >=0.11.4 , path >=0.9.5 , path-io , persistent >=2.14.0.0 && <2.19 diff --git a/stack.yaml b/stack.yaml index 8cf7acdaf5..64afbfdaae 100644 --- a/stack.yaml +++ b/stack.yaml @@ -39,7 +39,9 @@ extra-deps: # lts-24.43 specifies open-browser-0.4.0.0 - open-browser-0.5.1.0@sha256:0dc8dc33b9bba0e025e444355f6c2d806f62a4656446961c3647165f80f0d278,1959 # lts-24.43 specifies pantry-0.10.1 -- pantry-0.11.3@sha256:96fa2c7fa6cee9e470f984da567492f6bfaee058d14c1456f4f79b68a78d7be2,7668 +# We refer to the pull request at the pantry repository while testing Stack: +- github: commercialhaskell/pantry + commit: 7eae6adc4583f1cedb33f115a6396dfa78b57bb9 # lts-24.43 specifies persistent-2.17.1.0 - persistent-2.18.1.0@sha256:6a111b26c3e710f1e080a7543cf93766c4cc53ac560dbaa0d4b7ddc98a2f7b1d,7096 # lts-24.43 excludes ram diff --git a/stack.yaml.lock b/stack.yaml.lock index b0ef8bcd71..251acd4317 100644 --- a/stack.yaml.lock +++ b/stack.yaml.lock @@ -138,12 +138,16 @@ packages: original: hackage: open-browser-0.5.1.0@sha256:0dc8dc33b9bba0e025e444355f6c2d806f62a4656446961c3647165f80f0d278,1959 - completed: - hackage: pantry-0.11.3@sha256:96fa2c7fa6cee9e470f984da567492f6bfaee058d14c1456f4f79b68a78d7be2,7668 + name: pantry pantry-tree: - sha256: bedd749e9cfdb8adb1a253b34a3350aa89f5ca903aa341579351ce0a937af1f5 - size: 2722 + sha256: e9326d0cbb8e33197d4008bcedb61061b39ab820562cdbcb4bd07216af1a556f + size: 3763 + sha256: c41520e493e14baef2bdf14b529be1c13c3ee2a7055adffa3f1fbd8139d6d59f + size: 116083 + url: https://github.com/commercialhaskell/pantry/archive/7eae6adc4583f1cedb33f115a6396dfa78b57bb9.tar.gz + version: 0.11.4 original: - hackage: pantry-0.11.3@sha256:96fa2c7fa6cee9e470f984da567492f6bfaee058d14c1456f4f79b68a78d7be2,7668 + url: https://github.com/commercialhaskell/pantry/archive/7eae6adc4583f1cedb33f115a6396dfa78b57bb9.tar.gz - completed: hackage: persistent-2.18.1.0@sha256:6a111b26c3e710f1e080a7543cf93766c4cc53ac560dbaa0d4b7ddc98a2f7b1d,7096 pantry-tree: diff --git a/tests/integration/tests/6927-cyclic-snapshots/Main.hs b/tests/integration/tests/6927-cyclic-snapshots/Main.hs new file mode 100644 index 0000000000..1088cac986 --- /dev/null +++ b/tests/integration/tests/6927-cyclic-snapshots/Main.hs @@ -0,0 +1,32 @@ +-- | Stack detects when snapshot locations form a cycle and reports an error. +-- +-- See: https://github.com/commercialhaskell/stack/issues/6927 + +import Control.Monad ( unless ) +import Data.List ( isInfixOf ) +import StackTest + +main :: IO () +main = do + -- `stack build` makes use of pantry's loadAndCompleteSnapshotRaw': + stackErrStderr + ["--stack-yaml", "stack1.yaml", "build"] + (expectMessage cycleDetected) + stackErrStderr + ["--stack-yaml", "stack2.yaml", "build"] + (expectMessage cycleDetected) + -- `stack --snapshot list` makes use of pantry's loadSnapshot: + stackErrStderr + ["--snapshot", "my-snapshot.yaml", "list", "base"] + (expectMessage cycleDetected) + stackErrStderr + ["--snapshot", "my-snapshot1.yaml", "list", "base"] + (expectMessage cycleDetected) + +cycleDetected :: String +cycleDetected = "Cycle detected while reading snapshot." + +expectMessage :: String -> String -> IO () +expectMessage msg stderr = + unless (words msg `isInfixOf` words stderr) $ + error $ "Expected:\n\n" <> msg <> "\n\nin stderr, got:\n\n" <> stderr diff --git a/tests/integration/tests/6927-cyclic-snapshots/files/.gitignore b/tests/integration/tests/6927-cyclic-snapshots/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/6927-cyclic-snapshots/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/6927-cyclic-snapshots/files/my-snapshot.yaml b/tests/integration/tests/6927-cyclic-snapshots/files/my-snapshot.yaml new file mode 100644 index 0000000000..1202baffc0 --- /dev/null +++ b/tests/integration/tests/6927-cyclic-snapshots/files/my-snapshot.yaml @@ -0,0 +1,4 @@ +name: my-snapshot + +# In error, refers to itself: +snapshot: my-snapshot.yaml diff --git a/tests/integration/tests/6927-cyclic-snapshots/files/my-snapshot1.yaml b/tests/integration/tests/6927-cyclic-snapshots/files/my-snapshot1.yaml new file mode 100644 index 0000000000..d44681d28e --- /dev/null +++ b/tests/integration/tests/6927-cyclic-snapshots/files/my-snapshot1.yaml @@ -0,0 +1,3 @@ +name: my-snapshot1 + +snapshot: my-snapshot2.yaml diff --git a/tests/integration/tests/6927-cyclic-snapshots/files/my-snapshot2.yaml b/tests/integration/tests/6927-cyclic-snapshots/files/my-snapshot2.yaml new file mode 100644 index 0000000000..50193579bb --- /dev/null +++ b/tests/integration/tests/6927-cyclic-snapshots/files/my-snapshot2.yaml @@ -0,0 +1,3 @@ +name: my-snapshot2 + +snapshot: my-snapshot3.yaml diff --git a/tests/integration/tests/6927-cyclic-snapshots/files/my-snapshot3.yaml b/tests/integration/tests/6927-cyclic-snapshots/files/my-snapshot3.yaml new file mode 100644 index 0000000000..a480d21ade --- /dev/null +++ b/tests/integration/tests/6927-cyclic-snapshots/files/my-snapshot3.yaml @@ -0,0 +1,4 @@ +name: my-snapshot3 + +# In error, refers to my-snapshot1, creating a cycle: +snapshot: my-snapshot4.yaml diff --git a/tests/integration/tests/6927-cyclic-snapshots/files/my-snapshot4.yaml b/tests/integration/tests/6927-cyclic-snapshots/files/my-snapshot4.yaml new file mode 100644 index 0000000000..7953ee956c --- /dev/null +++ b/tests/integration/tests/6927-cyclic-snapshots/files/my-snapshot4.yaml @@ -0,0 +1,4 @@ +name: my-snapshot4 + +# In error, refers to my-snapshot2, creating a cycle: +snapshot: my-snapshot2.yaml diff --git a/tests/integration/tests/6927-cyclic-snapshots/files/package.yaml b/tests/integration/tests/6927-cyclic-snapshots/files/package.yaml new file mode 100644 index 0000000000..a7305a77cf --- /dev/null +++ b/tests/integration/tests/6927-cyclic-snapshots/files/package.yaml @@ -0,0 +1,9 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + +library: + source-dirs: src diff --git a/tests/integration/tests/6927-cyclic-snapshots/files/src/Lib.hs b/tests/integration/tests/6927-cyclic-snapshots/files/src/Lib.hs new file mode 100644 index 0000000000..6d85a26fe1 --- /dev/null +++ b/tests/integration/tests/6927-cyclic-snapshots/files/src/Lib.hs @@ -0,0 +1 @@ +module Lib where diff --git a/tests/integration/tests/6927-cyclic-snapshots/files/stack1.yaml b/tests/integration/tests/6927-cyclic-snapshots/files/stack1.yaml new file mode 100644 index 0000000000..c00072833e --- /dev/null +++ b/tests/integration/tests/6927-cyclic-snapshots/files/stack1.yaml @@ -0,0 +1 @@ +snapshot: my-snapshot.yaml diff --git a/tests/integration/tests/6927-cyclic-snapshots/files/stack2.yaml b/tests/integration/tests/6927-cyclic-snapshots/files/stack2.yaml new file mode 100644 index 0000000000..ed197c46ec --- /dev/null +++ b/tests/integration/tests/6927-cyclic-snapshots/files/stack2.yaml @@ -0,0 +1 @@ +snapshot: my-snapshot1.yaml