Repro: create a directory with the following two files:
# package.yaml
name: foo
dependencies:
- base
- haskell-src-exts
library: {}
# stack.yaml
resolver: lts-11.0
extra-deps:
- happy-1.19.9@rev:2
NOTE: If someone knows of a package in a Stackage snapshot that uses either happy or alex, and compiles quicker than haskell-src-exts, please let me know, we can make this repro easier to trigger.
Next: observe the following session:
$ stack build
happy-1.19.9: configure
happy-1.19.9: build
happy-1.19.9: copy/register
haskell-src-exts-1.20.2: configure
haskell-src-exts-1.20.2: build
haskell-src-exts-1.20.2: copy/register
foo-0.0.0: configure (lib)
Configuring foo-0.0.0...
foo-0.0.0: build (lib)
Preprocessing library for foo-0.0.0..
Building library for foo-0.0.0..
[1 of 1] Compiling Paths_foo ( .stack-work/dist/x86_64-osx/Cabal-2.0.1.0/build/autogen/Paths_foo.hs, .stack-work/dist/x86_64-osx/Cabal-2.0.1.0/build/Paths_foo.o )
foo-0.0.0: copy/register
Installing library in /Users/michael/Desktop/stack-build-tool-local/.stack-work/install/x86_64-osx/lts-11.0/8.2.2/lib/x86_64-osx-ghc-8.2.2/foo-0.0.0-J3VouLg1fVTLZlRnB5NxZt
Registering library for foo-0.0.0..
Completed 3 action(s).
Michaels-MacBook-Pro-3:stack-build-tool-local michael$ stack build --dry-run
Would unregister locally:
foo-0.0.0
haskell-src-exts-1.20.2
Would build:
foo-0.0.0: database=local, source=/Users/michael/Desktop/stack-build-tool-local/, after: haskell-src-exts-1.20.2
haskell-src-exts-1.20.2: database=local, source=package index
No executables to be installed.
Expected: the --dry-run call should report a no-op, since all of the packages have already been built.
Actual: it insists on rebuilding haskell-src-exts. The reason is clear when you look at the following --verbose bit of output:
[debug] Ignoring package haskell-src-exts, from (InstalledTo Local,"/Users/michael/Desktop/stack-build-tool-local/.stack-work/install/x86_64-osx/lts-11.0/8.2.2/pkgdb/"), due to wrong location: (Just (InstalledTo Local),Snap)
Stack believes that haskell-src-exts should appear in the snapshot database, since all of its dependencies are in the snapshot unchanged. However, this is a lie: one of its dependencies is actually happy as a build tool. But SourceMap construction does not consider build tools, and therefore the SourceMap and ConstructPlan steps are out of sync!
I think the most straightforward resolution is to move all of the build tool calculation to the SourceMap level.
Repro: create a directory with the following two files:
NOTE: If someone knows of a package in a Stackage snapshot that uses either happy or alex, and compiles quicker than
haskell-src-exts, please let me know, we can make this repro easier to trigger.Next: observe the following session:
Expected: the
--dry-runcall should report a no-op, since all of the packages have already been built.Actual: it insists on rebuilding
haskell-src-exts. The reason is clear when you look at the following--verbosebit of output:Stack believes that
haskell-src-extsshould appear in the snapshot database, since all of its dependencies are in the snapshot unchanged. However, this is a lie: one of its dependencies is actuallyhappyas a build tool. ButSourceMapconstruction does not consider build tools, and therefore theSourceMapandConstructPlansteps are out of sync!I think the most straightforward resolution is to move all of the build tool calculation to the
SourceMaplevel.