You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
causes a recalculation of all the dependencies (but no recompilation, after the first full build).
To Reproduce
See above
Expected behavior
I would expect (after the first full compilation) no further work by cabal.
System informataion
cabal --version
cabal-install version 2.4.1.0
compiled using version 2.4.1.0 of the Cabal library
on any GNU/Linux with any ghc.
Additional context
My projects are quite large with multiple .cabal packages and many hackage dependencies. Hence recalculation is quite costly (e.g. 30 seconds every time the dependencies are recomputed). I'm also using a freeze file.
In addition,
cabal v2-run tasty
vs
cabal v2-run tasty --enable-tests
exhibits the same problem.
A workaround is to always use --enable-tests even when doing v2-run tasty and even though it is redundant.
I also typically use -O0 for these commands, but that's probably irrelevant (much faster dev cycle).
I'm afraid that what you seem to be asking is at odds with the goal for cabal v2-build (and most other v2-* commands) to be stateless; if you want to be stateful, there's cabal v2-configure -- this is the only command that's supposed to persist the configuration settings which affects the solver (by modifying or creating your cabal.project.local).
And --enable-tests is such a solver input; if you toggle it, it will require the solver to be re-run. And since you're passing --enable-tests only to v2-build which by design is supposed to not persist the settings, and be forgetful about it on the next v2-build invocation (unless you re-pass the same flags), a solver recomputation is what you'll get.
However, one thing we could do is to create a solver-cache indexed by solver inputs, so that switching between cabal v2-build --enable-tests and cabal v2-build --disable-tests would be able to retrieve a previously cached plan w/ requiring a full resolving (if and only if all solver inputs remained the same).
This would be quite general, and would allow to quickly switch between various flag settings of v2-build instantly as long as the solver input has not been trashed; however, you might still end up recompiling things in every switch between solver-inputs if the build-plans are not cleanly overlapping, as in general, switching between --enable-tests and --disable-tests is not guaranteed have this kind of overlap (in your case you're increasing the likelihood by having a freeze file, but that's a particular case and not general)
I think the only part of this not covered by the other ticket is the idea that we could have multiple cached configurations and auto-swap between them? If so we should close this and then open a new ticket for that as a possible enhancement... (It could be a significant amount of design complexity though, depending on how many configs we want to save, with what sorts of different options, etc.)
Activity
hvr commentedon Jun 26, 2019
I'm afraid that what you seem to be asking is at odds with the goal for
cabal v2-build(and most otherv2-*commands) to be stateless; if you want to be stateful, there'scabal v2-configure-- this is the only command that's supposed to persist the configuration settings which affects the solver (by modifying or creating yourcabal.project.local).And
--enable-testsis such a solver input; if you toggle it, it will require the solver to be re-run. And since you're passing--enable-testsonly tov2-buildwhich by design is supposed to not persist the settings, and be forgetful about it on the nextv2-buildinvocation (unless you re-pass the same flags), a solver recomputation is what you'll get.However, one thing we could do is to create a solver-cache indexed by solver inputs, so that switching between
cabal v2-build --enable-testsandcabal v2-build --disable-testswould be able to retrieve a previously cached plan w/ requiring a full resolving (if and only if all solver inputs remained the same).This would be quite general, and would allow to quickly switch between various flag settings of
v2-buildinstantly as long as the solver input has not been trashed; however, you might still end up recompiling things in every switch between solver-inputs if the build-plans are not cleanly overlapping, as in general, switching between--enable-testsand--disable-testsis not guaranteed have this kind of overlap (in your case you're increasing the likelihood by having a freeze file, but that's a particular case and not general)gbaz commentedon Jun 26, 2019
I agree that a solver cache would be a very nice solution to this and related issues.
symbiont-sam-halliday commentedon Aug 29, 2019
I'm not sure if this is the same bug or not but using
--test-option(s)withv2-testalso causes recalculation (in cabal-install 3.0) and it shouldn't.[-]--enable-tests causes recalculation[/-][+]--enable-tests / --test-option(s) causes recalculation[/+]hvr commentedon Aug 29, 2019
it seems like
--test-optionisn't the only flag that has this effect from which one wouldn't expect this;another one is
--test-show-detailor--test-machine-logwhich seem to be considered input to the build-plan when modified:gbaz commentedon Sep 2, 2021
I think the only part of this not covered by the other ticket is the idea that we could have multiple cached configurations and auto-swap between them? If so we should close this and then open a new ticket for that as a possible enhancement... (It could be a significant amount of design complexity though, depending on how many configs we want to save, with what sorts of different options, etc.)