-
Notifications
You must be signed in to change notification settings - Fork 842
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stack build; stack test
rebuilds everything twice
#4977
Comments
Maybe it has something to do with using a custom Setup.hs? I try to create a repro if possible. If I recall correctly, the issue started to occur after I upgraded to stack version 2. stack says |
stack build; stack test
rebuilds everything twice
I sometimes observed this behavior, but it was not deterministic and I never tried to investigate it. I think I didn't observe it during last few months though. P. S. It's with default |
I can observe this reliably. Switching between |
If the compile flags need to change between building test and just building lib + exe then Stack would have to recompile everything, just like any other build system (just closed a similar issue with Bazel on another repo) If you can provide a minimal example, we can investigate to see if Stack is too eager in invalidating the build cache |
Here's an example using https://github.com/nikita-volkov/vector-builder:
Now I modify the last module in the build order, and
|
Thanks. Will investigate when I get a few cycles for open source |
One thing to add - for me it builds things only once if I do As a workaround I am always doing |
You could use |
@sjakobi Ok that sounds good 🙈 I have to admit I didn't really dig deep into all the things stack has to offer. I am using it for its great out of the box experience (Thank you stack developers for that!). And besides this problem I have not many other issues with it. |
Can also try That's what I used to do at previous place where we were using Haskell daily |
Building with |
Just in case if it helps i am facing the same issue with
In the case i run with
It tries to relink everything on each change. With |
Is this a duplicate of #2800? Looks similar from the outset, but the explanation given appears to be different (wrong dependencies added to library here and upstream issue there) — although it can be that both are true. I am also seeing similar behaviour, and I am confused as to where to put a |
@kindaro I would assume it's the same. |
The PureScript compiler suffers from the same symptoms as reported here. I currently work around it by downgrading to Stack 1.9, which doesn't appear to have the same problems. |
We do this by matching all build configurations and always include building tests. Performing a regular build without tests and then running the tests invalidates the previous build as test dependencies are added. See: - commercialhaskell/stack#4977 (comment) - commercialhaskell/stack#2800 (comment)
We do this by matching all build configurations and always include building tests. Performing a regular build without tests and then running the tests invalidates the previous build as test dependencies are added. See: - commercialhaskell/stack#4977 (comment) - commercialhaskell/stack#2800 (comment)
I have this problem and it is completely consistent: every time I switch between |
switching between |
What is working for me pretty much lately is to use a different build command: stack build --test --no-run-tests With this approach, you build all sources, including test, and after that, if you run The only problem with this is that if you are using some integrated environment with your IDE (haskell-server for example) this will launch a |
Try this in your build:
test: true
test-arguments:
no-run-tests: true
bench: true
benchmark-opts:
no-run-benchmarks: true See https://docs.haskellstack.org/en/latest/yaml_configuration/#build |
@hasufell That sounds like a great solution! How do I run the tests then? Does |
See: - commercialhaskell/stack#4977 (comment) - commercialhaskell/stack#2800 (comment)
@hasufell Unfortunately that seems to break |
@hasufell Instead of setting the arguments in stackBuild() { stack build --test --no-run-tests "$@"; } then run |
Now that I use My current workaround is a mess, but at least it works, for easy copy-and-paste:
|
I am new to this discussion. To summarise my own understanding:
|
@Javran, Stack's announcement that |
I am going to close this issue given the passage of time and because I can't reproduce the original issue with Stack 2.15.5, namely:
If it is still an issue with current versions, please reopen a fresh issue. |
omg @mpilgrem it's fixed. Holy cow. This is incredible. I can confirm that this is working well. |
Sharing my findings in case it is helpful to others. (Part of this is also conveyed in previous comments.) Once So if we do... stack clean
stack build --bench --no-run-benchmarks --test --no-run-tests
# compiles everything ...then thereafter, as long as stack build --bench --no-run-benchmarks
stack build --test --no-run-tests
stack build
stack build --bench --no-run-benchmarks --test --no-run-tests
stack build --bench --no-run-benchmarks --test --no-run-tests :myComponent
# ... Above I have added in If at any point The "good state" can be brought back with: # either: clean, then compile all in one go:
stack clean
stack build --bench --no-run-benchmarks --test --no-run-tests
# ...or: compile all in one go _twice_:
stack build --bench --no-run-benchmarks --test --no-run-tests
stack build --bench --no-run-benchmarks --test --no-run-tests It seems that one way to always stay in the good state is to make sure that each invocation of E.g. depending on what we actually want # run all benchmarks:
stack build --bench --test --no-run-tests
# run all tests:
stack build --bench --no-run-benchmarks --test
# run only test suite component :myTest:
stack build --bench --no-run-benchmarks --test :myTest Here's an example of a sequence of commands/actions + what # take us into the good state:
stack clean
stack build --bench --no-run-benchmarks --test --no-run-tests
# now we want to run all tests:
stack build --bench --no-run-benchmarks --test
# (re-compiles nothing)
# runs all tests
# HERE: edit a *test* source file
# now we want to run all benchmarks:
stack build --bench --test --no-run-tests
# re-compiles the test component of the edited source file
# (re-compiles nothing else)
# some re-linking
# runs all benchmarks
# now we want to run all tests:
stack build --bench --no-run-benchmarks --test
# (compiles nothing)
# runs all tests
Also possibly helpful in order to avoid unnecessary re-compilation is to make sure that all components have non-overlapping versions$ stack --version && stack exec -- ghc --version
# Version 2.15.5, Git revision 5649cc6b2522f51f0fc5543154b0fff868f9af31 aarch64 hpack-0.36.0
# The Glorious Glasgow Haskell Compilation System, version 9.6.6 |
Steps to reproduce
stack build
stack test
I am using stackage nightly. The library of my project is rebuild by
stack test
.Expected
The library should be compiled once and the compiled and cached output should be used.
Actual
stack test
recompiles the library.Stack version
Method of installation
The text was updated successfully, but these errors were encountered: