cabal icon indicating copy to clipboard operation
cabal copied to clipboard

Assertion failure at Distribution/Client/ProjectPlanning.hs:242:5 with --enable-documentation

Open sjakobi opened this issue 5 years ago • 14 comments

Repro:

≻ rm -rf propellor-5.7.0/
≻ cabal get propellor
Unpacking to propellor-5.7.0/
≻ cd propellor-5.7.0/
≻ cabal build --enable-documentation
Resolving dependencies...
Build profile: -w ghc-8.6.4 -O1
In order, the following will be built (use -v for more details):
Assertion failed
CallStack (from HasCallStack):
  assert, called at ./Distribution/Client/ProjectPlanning.hs:242:5 in main:Distribution.Client.ProjectPlanning

This is the problematic assertion:

https://github.com/haskell/cabal/blob/4061bfa2bff42b26c8240d19552dafa2e8252f75/cabal-install/Distribution/Client/ProjectPlanning.hs#L238-L244

sjakobi avatar Apr 19 '19 00:04 sjakobi

I can reproduce this and with tracing at the point of the assertion I see the build style is BuildAndInstall.

> cabal get propellor-5.7.0
> cd propellor-5.7.0/
> cabal v2-build all --enable-documentation
Resolving dependencies...
Build profile: -w ghc-8.2.2 -O1
In order, the following will be built (use -v for more details):
BuildAndInstall
 - Only-0.1 (lib) (requires build)
BuildAndInstall
 - base-compat-0.9.3 (lib) (requires build)
BuildAndInstall
 - base-orphans-0.7 (lib) (requires build)
BuildAndInstall
 - abstract-par-0.3.3 (lib) (requires build)
BuildAndInstall
 - cabal-doctest-1.0.8 (lib) (requires build)
BuildAndInstall
 - clock-0.7.2 (lib) (requires build)
BuildAndInstall
 - call-stack-0.1.0 (lib) (requires build)
BuildAndInstall
 - colour-2.3.4 (lib) (requires build)
BuildAndInstall
 - cmdargs-0.10.20 (lib) (requires build)
BuildAndInstall
 - cereal-0.5.7.0 (lib) (requires build)
BuildAndInstall
 - dlist-0.8.0.4 (lib) (requires build)
BuildAndInstall
 - data-default-class-0.1.2.0 (lib:data-default-class) (requires build)
BuildAndInstall
 - fgl-5.6.0.0 (lib) (requires build)
BuildAndInstall
 - fail-4.9.0.0 (lib) (requires build)
BuildAndInstall
 - fixed-0.2.1.1 (lib) (requires build)
BuildAndInstall
 - ghc-paths-0.1.0.9 (lib:ghc-paths) (requires build)
BuildAndInstall
 - ghc-tcplugins-extra-0.2.5 (lib) (requires build)
Assertion failed
CallStack (from HasCallStack):
  assert, called at ./Distribution/Client/ProjectPlanning.hs:244:5 in
main:Distribution.Client.ProjectPlanning

philderbeast avatar May 07 '20 14:05 philderbeast

Just ran into this issue trying to build documentation for dependencies of an executable, with a command of the form
cabal haddock exe:MyExe --enable-documentation

For the time being I re-compiled cabal-install without the assertion and the documentation builds as expected.

sheaf avatar Sep 03 '20 16:09 sheaf

Me too. With https://github.com/agda/agda/ commit 834b75908632e1633c0fe9b0ab1cd39195b51aa3:

$ cabal build --enable-tests --enable-documentation
Resolving dependencies...
Build profile: -w ghc-8.10.3 -O1
In order, the following will be built (use -v for more details):
 - ieee754-0.8.0 (lib:ieee754) (requires build)
 - STMonadTrans-0.4.5 (lib) (requires build)
 - blaze-builder-0.4.2.1 (lib) (requires build)
 - base-compat-0.11.2 (lib) (requires build)
 - base-orphans-0.8.4 (lib) (requires build)
 - clock-0.8.2 (lib) (requires build)
 - call-stack-0.3.0 (lib) (requires build)
 - colour-2.3.5 (lib) (requires build)
 - data-default-class-0.1.2.0 (lib:data-default-class) (requires build)
 - data-hash-0.2.0.1 (lib) (requires build)
 - fail-4.9.0.0 (lib) (requires build)
Assertion failed
CallStack (from HasCallStack):
  assert, called at src/Distribution/Client/ProjectPlanning.hs:237:5 in main:Distribution.Client.ProjectPlanning

$ cabal --version
cabal-install version 3.5.0.0
compiled using version 3.5.0.0 of the Cabal library 

(Recent development version of cabal-install.)

andreasabel avatar Feb 05 '21 18:02 andreasabel

Me too, current LambdaHack, almost current cabal from master branch. This cabal.project.local

package *
  documentation: True

repository head.hackage.ghc.haskell.org
   url: https://ghc.gitlab.haskell.org/head.hackage/
   secure: True
   key-threshold: 3
   root-keys:
       7541f32a4ccca4f97aea3b22f5e593ba2c0267546016b992dfadcd2fe944e55d
       26021a13b401500c8eb2761ca95c61f2d625bfef951b939a8124ed12ecf07329
       f76d08be13e9a61a377a85e2fb63f4c5435d40f8feb3e12eb05905edb8cdea89

causes

~/r/LambdaHack$ cabal build -w /home/mikolaj/r/ghc/_build/stage1/bin/ghc --allow-newer
Build profile: -w ghc-9.3.20220316 -O1
In order, the following will be built (use -v for more details):
 - StateVar-1.2.2 (lib) (requires build)
 - base-compat-0.12.1 (lib) (requires build)
 - base-orphans-0.8.6 (lib) (requires build)
 - colour-2.3.6 (lib) (requires build)
 - file-embed-0.0.15.0 (lib) (requires build)
Assertion failed
CallStack (from HasCallStack):
  assert, called at src/Distribution/Client/ProjectPlanning.hs:243:5 in cabal-install-3.7.0.0-inplace:Distribution.Client.ProjectPlanning

Mikolaj avatar Mar 22 '22 10:03 Mikolaj

This is happening to many people in many tickets over the years, so I'm bumping priority.

Mikolaj avatar Mar 22 '22 10:03 Mikolaj

Another instance:

  • #8313

andreasabel avatar Jul 23 '22 09:07 andreasabel

As of cabal-install-3.8.1.0, I'm getting a proper error message for the original reproducer:

$ cabal build --enable-documentation -w ghc-8.6
Resolving dependencies...
Build profile: -w ghc-8.6.5 -O1
In order, the following will be built (use -v for more details):
 - propellor-5.7.0 (lib) (first run)
 - propellor-5.7.0 (exe:propellor-config) (first run)
 - propellor-5.7.0 (exe:propellor) (first run)
Configuring library for propellor-5.7.0..
Error: cabal-3.8.1.0: Duplicate modules in library: Utility.Scheduled

Error: cabal: Failed to build propellor-5.7.0 (which is required by
exe:propellor-config from propellor-5.7.0 and exe:propellor from
propellor-5.7.0). The failure occurred during the configure step.

If I remove the duplicate module from the exposed-modules section, I get a clean build for the same command.


EDIT: propellor issue: https://propellor.branchable.com/todo/Deduplicate_exposed-modules/

sjakobi avatar Aug 10 '22 08:08 sjakobi

Great news! Should this be closed?

ulysses4ever avatar Aug 10 '22 12:08 ulysses4ever

Should this be closed?

I wouldn't mind. It might be interesting to check whether the instances reported in https://github.com/haskell/cabal/issues/6006#issuecomment-774214724 and https://github.com/haskell/cabal/issues/6006#issuecomment-1074982814 are also fixed though.

sjakobi avatar Aug 10 '22 12:08 sjakobi

Right... I doubt all of them had the same issue with duplicate modules. And also, wasn't it only appearing when you use cabal built with assertions on, so not releases?

On the other note, I'm failing to repro Andreas' example in https://github.com/haskell/cabal/issues/6006#issuecomment-774214724 with the current master.

ulysses4ever avatar Aug 10 '22 15:08 ulysses4ever

On the other note, I'm failing to repro Andreas' example in #6006 (comment) with the current master.

Still reproduces on my machine.

andreasabel avatar Aug 10 '22 17:08 andreasabel

And also, wasn't it only appearing when you use cabal built with assertions on, so not releases?

I just tried the original reproducer (propellor-5.7.0) with a version of cabal built from this repo at the cabal-install-v3.8.1.0 tag, so assertions should be enabled (I think). I'm still getting the Duplicate modules error with this version of cabal.

sjakobi avatar Aug 10 '22 20:08 sjakobi

@sjakobi: if you didn't build with cabal.project.release (as README suggests), but with the default cabal.project then the assertions should be enabled. Do I understand the Duplicate modules error is fine? It's the assertion failure crash that is bad?

Mikolaj avatar Aug 11 '22 09:08 Mikolaj

Do I understand the Duplicate modules error is fine? It's the assertion failure crash that is bad?

Yes, the Duplicate modules error is good UX IMHO. The assertion failure seemed to indicate a internal logic bug in cabal-install which might be worth investigating.

sjakobi avatar Aug 11 '22 10:08 sjakobi

As discussed on IRC today, this assert is very harmful to testing developer builds, so that it's worth disabling for the time being. Hopefully a brave soul will once find out why it's failing. See https://github.com/haskell/cabal/pull/8821.

ulysses4ever avatar Feb 28 '23 20:02 ulysses4ever

I think this assertion should be fixed because it means something is inconsistent between what the hash inputs were when the elabComponentId was calculated and the inputs computed from the ElaboratedConfigurePackage.. these should definitely be the same as each other.

I think this could lead to things going quite wrong (but I am not sure how) The way to investigate is to print out the packageHashInputs to see where the difference is and then work out why it's different for the two cases.

mpickering avatar Mar 12 '23 18:03 mpickering