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
{{ message }}
Repository navigation
Install test executables with cabal install when "--enable-tests" present #7693
Describe the bug
Trying to manually (because included Makefile forces v1- commands) build Agda from source, I'm getting the following error:
$ cabal v2-install --enable-tests --disable-documentation --only-dependencies -fenable-cluster-counting
cabal: --enable-tests was specified, but tests can't be enabled in a remote
package
Expected behavior
Successful build. I am getting it when I omit --enable-tests, but in that case agda-tests executable is not built (so, I can't run tests to validate the created executables).
Note, that cabal v2-build --enable-tests seems to work fine (but it does not install the executables it builds).
To spell it out, you did --only-dependencies and cabal is confused (do you want to run tests for the dependencies?), though perhaps it shouldn't be, see the ticket @fgaz mentioned.
To spell it out, you did --only-dependencies and cabal is confused (do you want to run tests for the dependencies?),
I want to build/install Agda, and run the tests. If I do build and run tests first, and then install - it will recompile everything again, which is a fairly lengthy process. Doing it in one swoop via install makes it to compile the whole thing only once. And that's how it works with v1-install. But since v1- has unpleasant effect on the global environment, I'd much rather get it working with v2-.
. . . though perhaps it shouldn't be, see the ticket @fgaz mentioned.
It would be great if this obstacle were taken care of.
-- We never try to build tests/benchmarks for remote packages.
-- So we set them as disabled by default and error if they are explicitly
-- enabled.
when (configTests configFlags ==FlagTrue) $
die' verbosity $"--enable-tests was specified, but tests can't "
++"be enabled in a remote package"
when (configBenchmarks configFlags ==FlagTrue) $
die' verbosity $"--enable-benchmarks was specified, but benchmarks can't "
++"be enabled in a remote package"
and there is no assertion failure, though tests aren't actually built. Maybe we just need the equivalent of #5143. I won't investigate this further right now though
changed the title [-]Strange failure when "--enable-tests" present[/-][+]Install test executables with cabal install when "--enable-tests" present[/+]on Sep 29, 2021
I hope that's not true (otherwise, please report). I you build and test and install with the same flags, it should not rebuild any Haskell files, though it will re-link.
I hope that's not true (otherwise, please report). I you build and test and install with the same flags, it should not rebuild any Haskell files, though it will re-link.
I hope that's not true (otherwise, please report). I you build and test and install with the same flags, it should not rebuild any Haskell files, though it will re-link.
The example from #6919 is very sad but, if you squint, it's excluded by the "with the same flags" proviso (targets being not exactly flags, but being at least commandline arguments). And I've heard that stuff gets rebuilt without a good reason in other cases, which is why I'm fishing for a reproducible example.
It's still true even with the same flags: when installing, local packages are treated as remote and have to be rebuilt in the store
So the "I notice that, if I cabal build exe:propellor, the cabal install does not re-build" success is not caused by the agreement of flags, but by cabal buil treating local packages as remote in some cases?
The example from #6919 is very sad but, if you squint, it's excluded by the "with the same flags" proviso (targets being not exactly flags, but being at least commandline arguments).
Strictly speaking, those are different flags, albeit slightly. As I understand (please correct me if I'm wrong), --enable-tests is not just about running the tests, it's about building in a different way that supports running the tests. Therefore, the resulting binaries for all the packages involved - the targets and their dependencies - will be different based on the presence or absence of --enable-tests flag.
That's not unique to Haskell/Cabal - in C people debug and test with -g -O0, but deploy to production with -O3 or better. Meaning that what was tested is not what actually runs in production. It is known to cause real problems in real life - for example: randombit/botan#2802
. . . do you want to run tests for the dependencies?
To revisit this question - no, I don't really want to run tests on/for the dependencies - but these dependencies must be ready to support running tests on my project's target. I suspect, in the end there isn't much difference between whether I want to actually run tests for the dependencies, or merely build and install those dependencies in such a way that they can support their caller running tests.
Thus, I think that the correct behavior for Cabal in such a case should be - build the dependencies as if I were to run the tests for them, regardless of whether they are local or remote.
I don't even understand the --only-dependencies flag here. It doesn't make a lot of sense in this workflow given how v-2 works. I think the flags are asking for something a bit nonsensical and the current behavior looks fine.
I think it is correct that install does not allow tests, since it doesn't make much sense.
To get the workflow you desire, you can just build with tests, then manually copy or symlink the binary. A future feature request could be to add a copy/symlink binary flag to the build of an executable.
I think it is correct that install does not allow tests, since it doesn't make much sense.
IMHO, on the contrary - it makes great sense to be able to run the test suite over the "production" (aka, installed) executable... At the very least, you'll know that the actual physical binary that passed or failed your tests is the same that is running your high-value tasks in deployment.
. . . can't reproduce the deps being rebuilt when trying an install after a build with --enable-tests
A sure reproducer for me in Agda repo itself - a bit on the big side, but should suffice as a proof...
All of my toy projects are trivially small, so not representative...
Note that it appears only a small subset of libs are being rebuilt, so its not a general issue, but something pertaining to those libs in particular.
Or, rather, a general issue impacting specific conditions. I doubt it's specific to individual libs/packages - probably, specific to what flags their project files define...?
This may have to do with the dynamic linking opts in your ~/cabal.config
No doubt, dynamic linking exacerbates the problem. Though I doubt it causes it.
if you run cabal-plan info you get detailed information about the build plan. There's even a cabal-plan diff command that could help you pinpoint the cause
if you run cabal-plan info you get detailed information about the build plan. There's even a cabal-plan diff command that could help you pinpoint the cause
My apologies for being dense. Say, I have a pristine/clean clone of the repo, ready for cabal build and such. What would be the sequence of commands, including cabal-plan ... that you suggest I run?
So not sure if my test is correct but i tried a raw cabal build -w ghc-8.10.7 and then cabal install -w ghc-8.10.7 and many dependencies has been rebuilt:
I've added the cabal-plan output for the temporal dir where the build triggered by cabal install is done
For completeness: i did no config nor other file changes between build and install
My guess is all unit IDs will be different and there will be duplicated entries in store PKG db and being unit IDs an opaque output a trace of the inputs will be needed, is the computation of unit IDs including the inputs being traced?
i also guess it could be a windows specific thing, as it seems it is not reproduced in Linux
Edit: apparently, the below doesn't make sense apart of pointing out the connection to #7297, see two comments down.
.
@jneira: I do not claim to understand this, but @phadej says it's expected and hard to avoid that unit IDs differ between build and install: #7297 (comment)
Given that, I guess it's unavoidable that rebuilds occur. Perhaps we need to dig deeper into the IDs and/or #7297.
Sanity check: the unit IDs in the plans you attached do differ, right?
@phadej says it's expected and hard to avoid that unit IDs differ between build and install: #7297 (comment)
If dependencies get installed during build (rather than placed in the local dist-newstyle/) - there's no reason for and no sense in their unit IDs changing install from their build values.
@Mikolaj I think you misinterpreted oleg's comment. The point is that if I "install" or "build" a package, its own hash may be different in those two circumstances. In either case, the packages it depends on will unilaterally be installed into the store. So the differences he's highlighting are not the relevant ones.
@mouse07410 please keep your comments here constructive. Stomping your foot and repeating yourself, saying "that's a bug that needs fixing" while we're still trying to investigate what the reported issue even is, and if we can reproduce it is just adding noise and confusion that's making sorting this out harder. We know what your intuition is. The complicated reality of the system may not conform to that, and maybe the result will be fixing a bug, maybe it will be us understanding and documenting the system better, or maybe it will be realizing that a change could be possible but would require far too much work to be feasible. We don't know, and what we need to do now is patiently investigate, not repeat the same initial concerns.
Well, there is one relevant case: if a remote package depends on a local package, the remote package and all its reverse dependencies will be rebuilt. This can happen if one vendors a package deep in the dependency tree. I see no such thing in the Agda repo though.
What would be the sequence of commands, including cabal-plan ... that you suggest I run?
there is one relevant case: if a remote package depends on a local package, the remote package and all its reverse dependencies will be rebuilt. This can happen if one vendors a package deep in the dependency tree.
I'm afraid you lost me here - I don't see how it could be possible for a dependency package (presumably already on Hackage) to depend in turn on the (presumably local) package being currently built. Most likely, I just don't understand the example.
this should work but i did not test it: . . .
Well, in my case, since I've already tried both cabal v2-build ... and cabal v2-install ..., it appears that the packages build and installed by both commands are still in the global store. So, the output of cabal-plan diff ... is not impressive - I'm not sure if it's helpful for you to pinpoint the problem:
OK, pulled updates from Agda repo, tried again. Since cabal-plan diffshows some things by "boldifying" elements of the build tree, it seems best to post the screenshots, rather than the mere textual content:
Ok, i think we are out of the issue topic now, it asks for installing executables with cabal install --enable-tests.
One of the main motivations was the rebuild between build and install, but there is a specific issue about #6919 as noted by @fgaz. So i am gonna post my tests about there.
EDIT: I ended to open a new issue #7745, as #6919 is about rebuilding local packages and in my case cabal rebuilds all the deps too
Activity
fgaz commentedon Sep 29, 2021
This is intended:
cabal/cabal-install/src/Distribution/Client/CmdInstall.hs
Lines 408 to 416 in 103adec
It was introduced in #4879 to fix #4855. Things might have changed since then though (eg. #4886 (comment)), judging by eg. #5143
Mikolaj commentedon Sep 29, 2021
To spell it out, you did
--only-dependenciesand cabal is confused (do you want to run tests for the dependencies?), though perhaps it shouldn't be, see the ticket @fgaz mentioned.mouse07410 commentedon Sep 29, 2021
I want to build/install Agda, and run the tests. If I do
buildand run tests first, and then install - it will recompile everything again, which is a fairly lengthy process. Doing it in one swoop via install makes it to compile the whole thing only once. And that's how it works withv1-install. But sincev1-has unpleasant effect on the global environment, I'd much rather get it working withv2-.It would be great if this obstacle were taken care of.
fgaz commentedon Sep 29, 2021
I just tried removing
cabal/cabal-install/src/Distribution/Client/CmdInstall.hs
Lines 408 to 416 in 103adec
and there is no assertion failure, though tests aren't actually built. Maybe we just need the equivalent of #5143. I won't investigate this further right now though
[-]Strange failure when "--enable-tests" present[/-][+]Install test executables with cabal install when "--enable-tests" present[/+]Mikolaj commentedon Sep 29, 2021
So why do you do
--only-dependencies?I hope that's not true (otherwise, please report). I you
buildandtestandinstallwith the same flags, it should not rebuild any Haskell files, though it will re-link.fgaz commentedon Sep 29, 2021
unfortunately it's true for install: #6919
Mikolaj commentedon Sep 29, 2021
The example from #6919 is very sad but, if you squint, it's excluded by the "with the same flags" proviso (targets being not exactly flags, but being at least commandline arguments). And I've heard that stuff gets rebuilt without a good reason in other cases, which is why I'm fishing for a reproducible example.
fgaz commentedon Sep 29, 2021
It's still true even with the same flags: when installing, local packages are treated as remote and have to be rebuilt in the store
Mikolaj commentedon Sep 29, 2021
So the "I notice that, if I
cabal build exe:propellor, thecabal installdoes not re-build" success is not caused by the agreement of flags, but bycabal builtreating local packages as remote in some cases?mouse07410 commentedon Sep 29, 2021
Strictly speaking, those are different flags, albeit slightly. As I understand (please correct me if I'm wrong),
--enable-testsis not just about running the tests, it's about building in a different way that supports running the tests. Therefore, the resulting binaries for all the packages involved - the targets and their dependencies - will be different based on the presence or absence of--enable-testsflag.That's not unique to Haskell/Cabal - in C people debug and test with
-g -O0, but deploy to production with-O3or better. Meaning that what was tested is not what actually runs in production. It is known to cause real problems in real life - for example: randombit/botan#2802To revisit this question - no, I don't really want to run tests on/for the dependencies - but these dependencies must be ready to support running tests on my project's target. I suspect, in the end there isn't much difference between whether I want to actually run tests for the dependencies, or merely build and install those dependencies in such a way that they can support their caller running tests.
Thus, I think that the correct behavior for Cabal in such a case should be - build the dependencies as if I were to run the tests for them, regardless of whether they are local or remote.
Comments, please?
gbaz commentedon Sep 29, 2021
I don't even understand the --only-dependencies flag here. It doesn't make a lot of sense in this workflow given how v-2 works. I think the flags are asking for something a bit nonsensical and the current behavior looks fine.
I think it is correct that install does not allow tests, since it doesn't make much sense.
To get the workflow you desire, you can just build with tests, then manually copy or symlink the binary. A future feature request could be to add a copy/symlink binary flag to the build of an executable.
mouse07410 commentedon Sep 29, 2021
IMHO, on the contrary - it makes great sense to be able to run the test suite over the "production" (aka, installed) executable... At the very least, you'll know that the actual physical binary that passed or failed your tests is the same that is running your high-value tasks in deployment.
What am I missing?
31 remaining items
gbaz commentedon Oct 10, 2021
Just tried this (though with ghc 8.10.4) and can't reproduce the deps being rebuilt when trying an install after a build with --enable-tests.
Note that it appears only a small subset of libs are being rebuilt, so its not a general issue, but something pertaining to those libs in particular.
This may have to do with the dynamic linking opts in your ~/cabal.config
mouse07410 commentedon Oct 10, 2021
A sure reproducer for me in Agda repo itself - a bit on the big side, but should suffice as a proof...
All of my toy projects are trivially small, so not representative...
Or, rather, a general issue impacting specific conditions. I doubt it's specific to individual libs/packages - probably, specific to what flags their project files define...?
No doubt, dynamic linking exacerbates the problem. Though I doubt it causes it.
gbaz commentedon Oct 10, 2021
I literally tried this with the agda repo. I couldn't reproduce.
fgaz commentedon Oct 10, 2021
Same and same.
if you run
cabal-plan infoyou get detailed information about the build plan. There's even acabal-plan diffcommand that could help you pinpoint the causemouse07410 commentedon Oct 10, 2021
My apologies for being dense. Say, I have a pristine/clean clone of the repo, ready for
cabal buildand such. What would be the sequence of commands, includingcabal-plan ...that you suggest I run?mouse07410 commentedon Oct 10, 2021
@gbaz and @fgaz would it be possible for you to re-try the same with (a) dynamic build (editing
~/.cabal/config), and/or (b) the current GHC-9.0.1?jneira commentedon Oct 11, 2021
So not sure if my test is correct but i tried a raw
cabal build -w ghc-8.10.7and thencabal install -w ghc-8.10.7and many dependencies has been rebuilt:List of dependencies
This is the cabal plan after
cabal build:cabal-plan output
cabal plan after
cabal installcabal-plan output
And finally the output of cabal-plan in the temp dir used for build by
cabal installOutput of `cabal-plan info --builddir C:\TEMP\cabal-install.-19884\dist-newstyle`
EDIT:
cabal installis doneMikolaj commentedon Oct 11, 2021
Edit: apparently, the below doesn't make sense apart of pointing out the connection to #7297, see two comments down.
.
@jneira: I do not claim to understand this, but @phadej says it's expected and hard to avoid that unit IDs differ between build and install: #7297 (comment)
Given that, I guess it's unavoidable that rebuilds occur. Perhaps we need to dig deeper into the IDs and/or #7297.
Sanity check: the unit IDs in the plans you attached do differ, right?
mouse07410 commentedon Oct 11, 2021
If dependencies get installed during build (rather than placed in the local
dist-newstyle/) - there's no reason for and no sense in their unit IDs changing install from their build values.gbaz commentedon Oct 12, 2021
@Mikolaj I think you misinterpreted oleg's comment. The point is that if I "install" or "build" a package, its own hash may be different in those two circumstances. In either case, the packages it depends on will unilaterally be installed into the store. So the differences he's highlighting are not the relevant ones.
@mouse07410 please keep your comments here constructive. Stomping your foot and repeating yourself, saying "that's a bug that needs fixing" while we're still trying to investigate what the reported issue even is, and if we can reproduce it is just adding noise and confusion that's making sorting this out harder. We know what your intuition is. The complicated reality of the system may not conform to that, and maybe the result will be fixing a bug, maybe it will be us understanding and documenting the system better, or maybe it will be realizing that a change could be possible but would require far too much work to be feasible. We don't know, and what we need to do now is patiently investigate, not repeat the same initial concerns.
fgaz commentedon Oct 12, 2021
Well, there is one relevant case: if a remote package depends on a local package, the remote package and all its reverse dependencies will be rebuilt. This can happen if one vendors a package deep in the dependency tree. I see no such thing in the Agda repo though.
this should work but i did not test it:
see
cabal-plan --helpandcabal-plan diff --helpfor more. fyi,plan.jsonis in$builddir/cachemouse07410 commentedon Oct 12, 2021
I'm afraid you lost me here - I don't see how it could be possible for a dependency package (presumably already on Hackage) to depend in turn on the (presumably local) package being currently built. Most likely, I just don't understand the example.
Well, in my case, since I've already tried both
cabal v2-build ...andcabal v2-install ..., it appears that the packages build and installed by both commands are still in the global store. So, the output ofcabal-plan diff ...is not impressive - I'm not sure if it's helpful for you to pinpoint the problem:mouse07410 commentedon Oct 12, 2021
OK, pulled updates from Agda repo, tried again. Since
cabal-plan diffshows some things by "boldifying" elements of the build tree, it seems best to post the screenshots, rather than the mere textual content:jneira commentedon Oct 12, 2021
Ok, i think we are out of the issue topic now, it asks for installing executables with
cabal install --enable-tests.One of the main motivations was the rebuild between build and install, but there is a specific issue about #6919 as noted by @fgaz. So i am gonna post my tests about there.
EDIT: I ended to open a new issue #7745, as #6919 is about rebuilding local packages and in my case cabal rebuilds all the deps too