Using a snapshot field in a stack.yaml project is a bit like an import isn't it but with some restrictions. If there is a cycle between these imports then Stack hangs or overflows the stack with the build, clean and purge commands.
Steps to reproduce
It was hanging but here I set the stack size to show the overflow:
$ cat stack.yaml
snapshot: stack.fwd.yaml
packages: [.]
$ cat stack.fwd.yaml
snapshot: stack.bwd.yaml
$ cat stack.bwd.yaml
snapshot: stack.fwd.yaml
$ GHCRTS='-K1m' stack build
stack: Stack space overflow: current size 33608 bytes.
stack: Use `+RTS -Ksize -RTS' to increase it.
$ GHCRTS='-K1m' stack clean
stack: Stack space overflow: current size 33608 bytes.
stack: Use `+RTS -Ksize -RTS' to increase it.
GHCRTS='-K1m' stack purge
stack: Stack space overflow: current size 33608 bytes.
stack: Use `+RTS -Ksize -RTS' to increase it.
Expected
The snapshot import cycle is detected and stopped.
Stack version
Also happens with 3.9.3.
$ stack --version
Version 3.12.0, Git revision 971deb7280f2007d15f2e86f97a979fa22506deb (11752 commits) PRE-RELEASE x86_64
Method of installation
Platform
Ubuntu 25.10
Using a
snapshotfield in astack.yamlproject is a bit like an import isn't it but with some restrictions. If there is a cycle between these imports then Stack hangs or overflows the stack with thebuild,cleanandpurgecommands.Steps to reproduce
It was hanging but here I set the stack size to show the overflow:
Note
Found while testing well-typed/haskell-debugger#322.
That project builds with
GHCRTS='-K1m' stack build.Expected
The snapshot import cycle is detected and stopped.
Stack version
Also happens with
3.9.3.Method of installation
3.9.3Platform
Ubuntu 25.10