cabal icon indicating copy to clipboard operation
cabal copied to clipboard

[3.12.0.0] Failed to find the installed unit

Open jasagredo opened this issue 1 year ago • 1 comments

Describe the bug

Building a package with cabal 3.12.0.0, I encountered this error:

> cabal test all
...
Error: [Cabal-9341]
Failed to find the installed unit 'cardano-submit-api-3.2.2-inplace' in package database stack.
...
Error: [Cabal-7125]
Tests failed for test:unit from cardano-submit-api-3.2.2.

Output

A subsequent cabal build all was able to find the library and build it, Output collapsed below:

Output

To Reproduce Not sure how to reproduce it. I used the branch https://github.com/IntersectMBO/cardano-node/tree/js/cabal-error-report. I had compiled the project before the latest commit, and then after updating those source-repository-package this error showed up, but it doesn't seem to be deterministic :(

System information

  • Operating system: Windows 11 + WSL Ubuntu 22.04.4
  • cabal, ghc versions:
❯ cabal --version && ghc --version
cabal-install version 3.11.0.0
compiled using version 3.12.0.0 of the Cabal library
The Glorious Glasgow Haskell Compilation System, version 9.8.2

Additional context In this same scenario I saw a paraphrasing of the following error (but I lost the terminal output, I will make a proper issue if I see it again, but maybe it is helpful to guess the cause):

When building ouroboros-consensus-cardano:
Encountered private or missing dependencies:
  diff-containers >= 1.1

A cabal clean && cabal build all solved it. Perhaps cabal clean would not have been needed.

jasagredo avatar May 23 '24 11:05 jasagredo

Another instance of the same problem at commit 55172e6ab25522853826fc95f4f2e26d2f2d8176 in https://github.com/IntersectMBO/ouroboros-consensus

ouroboros-consensus on  js/removeNS [$] via λ 9.8.2 took 22s
❯ cabal clean

ouroboros-consensus on  js/removeNS [$] via λ 9.8.2
❯ cabal test all
Resolving dependencies...
Build profile: -w ghc-9.8.2 -O1
In order, the following will be built (use -v for more details):
 - ouroboros-consensus-0.18.0.0 (test:doctest) (first run)
 - strict-sop-core-0.1.1.0 (lib) (first run)
 - sop-extras-0.2.0.0 (lib) (first run)
 - ouroboros-consensus-0.18.0.0 (lib) (first run)
 - ouroboros-consensus-protocol-0.9.0.0 (lib) (first run)
 - ouroboros-consensus-diffusion-0.16.0.0 (lib) (first run)
 - ouroboros-consensus-cardano-0.16.0.0 (lib:unstable-byronspec) (first run)
 - ouroboros-consensus-0.18.0.0 (lib:unstable-mempool-test-utils) (first run)
 - ouroboros-consensus-0.18.0.0 (lib:unstable-consensus-testlib) (first run)
 - ouroboros-consensus-protocol-0.9.0.0 (lib:unstable-protocol-testlib) (first run)
 - ouroboros-consensus-cardano-0.16.0.0 (lib) (first run)
 - ouroboros-consensus-protocol-0.9.0.0 (test:protocol-test) (first run)
 - ouroboros-consensus-diffusion-0.16.0.0 (lib:unstable-diffusion-testlib) (first run)
 - ouroboros-consensus-0.18.0.0 (lib:unstable-mock-block) (first run)
 - ouroboros-consensus-0.18.0.0 (test:storage-test) (first run)
 - ouroboros-consensus-0.18.0.0 (test:infra-test) (first run)
 - ouroboros-consensus-cardano-0.16.0.0 (lib:unstable-cardano-tools) (first run)
 - ouroboros-consensus-diffusion-0.16.0.0 (test:infra-test) (first run)
 - ouroboros-consensus-diffusion-0.16.0.0 (test:consensus-test) (first run)
 - ouroboros-consensus-cardano-0.16.0.0 (lib:unstable-shelley-testlib) (first run)
 - ouroboros-consensus-cardano-0.16.0.0 (lib:unstable-byron-testlib) (first run)
 - ouroboros-consensus-diffusion-0.16.0.0 (lib:unstable-mock-testlib) (first run)
 - ouroboros-consensus-0.18.0.0 (test:consensus-test) (first run)
 - ouroboros-consensus-cardano-0.16.0.0 (test:tools-test) (first run)
 - ouroboros-consensus-cardano-0.16.0.0 (test:shelley-test) (first run)
 - ouroboros-consensus-cardano-0.16.0.0 (lib:unstable-cardano-testlib) (first run)
 - ouroboros-consensus-cardano-0.16.0.0 (test:byron-test) (first run)
 - ouroboros-consensus-diffusion-0.16.0.0 (test:mock-test) (first run)
 - ouroboros-consensus-cardano-0.16.0.0 (test:cardano-test) (first run)
Configuring library for strict-sop-core-0.1.1.0...
Configuring test suite 'doctest' for ouroboros-consensus-0.18.0.0...
Preprocessing library for strict-sop-core-0.1.1.0...
Building library for strict-sop-core-0.1.1.0...
Preprocessing test suite 'doctest' for ouroboros-consensus-0.18.0.0...
Building test suite 'doctest' for ouroboros-consensus-0.18.0.0...
[1 of 3] Compiling Data.SOP.Strict.NP ( src/Data/SOP/Strict/NP.hs, /home/javier/cardano/ouroboros-consensus/dist-newstyle/build/x86_64-linux/ghc-9.8.2/strict-sop-core-0.1.1.0/build/Data/SOP/Strict/NP.o, /home/javier/cardano/ouroboros-consensus/dist-newstyle/build/x86_64-linux/ghc-9.8.2/strict-sop-core-0.1.1.0/build/Data/SOP/Strict/NP.dyn_o )
[1 of 1] Compiling Main             ( test/doctest.hs, /home/javier/cardano/ouroboros-consensus/dist-newstyle/build/x86_64-linux/ghc-9.8.2/ouroboros-consensus-0.18.0.0/t/doctest/build/doctest/doctest-tmp/Main.o )
[2 of 2] Linking /home/javier/cardano/ouroboros-consensus/dist-newstyle/build/x86_64-linux/ghc-9.8.2/ouroboros-consensus-0.18.0.0/t/doctest/build/doctest/doctest
[2 of 3] Compiling Data.SOP.Strict.NS ( src/Data/SOP/Strict/NS.hs, /home/javier/cardano/ouroboros-consensus/dist-newstyle/build/x86_64-linux/ghc-9.8.2/strict-sop-core-0.1.1.0/build/Data/SOP/Strict/NS.o, /home/javier/cardano/ouroboros-consensus/dist-newstyle/build/x86_64-linux/ghc-9.8.2/strict-sop-core-0.1.1.0/build/Data/SOP/Strict/NS.dyn_o )
[3 of 3] Compiling Data.SOP.Strict  ( src/Data/SOP/Strict.hs, /home/javier/cardano/ouroboros-consensus/dist-newstyle/build/x86_64-linux/ghc-9.8.2/strict-sop-core-0.1.1.0/build/Data/SOP/Strict.o, /home/javier/cardano/ouroboros-consensus/dist-newstyle/build/x86_64-linux/ghc-9.8.2/strict-sop-core-0.1.1.0/build/Data/SOP/Strict.dyn_o )
Configuring library for sop-extras-0.2.0.0...
Error: [Cabal-9341]
Failed to find the installed unit 'ouroboros-consensus-0.18.0.0-inplace' in package database stack.

Preprocessing library for sop-extras-0.2.0.0...
Building library for sop-extras-0.2.0.0...
[ 1 of 10] Compiling Data.SOP.Functors ( src/Data/SOP/Functors.hs, /home/javier/cardano/ouroboros-consensus/dist-newstyle/build/x86_64-linux/ghc-9.8.2/sop-extras-0.2.0.0/build/Data/SOP/Functors.o, /home/javier/cardano/ouroboros-consensus/dist-newstyle/build/x86_64-linux/ghc-9.8.2/sop-extras-0.2.0.0/build/Data/SOP/Functors.dyn_o )
[ 2 of 10] Compiling Data.SOP.Index   ( src/Data/SOP/Index.hs, /home/javier/cardano/ouroboros-consensus/dist-newstyle/build/x86_64-linux/ghc-9.8.2/sop-extras-0.2.0.0/build/Data/SOP/Index.o, /home/javier/cardano/ouroboros-consensus/dist-newstyle/build/x86_64-linux/ghc-9.8.2/sop-extras-0.2.0.0/build/Data/SOP/Index.dyn_o )
[ 3 of 10] Compiling Data.SOP.Lenses  ( src/Data/SOP/Lenses.hs, /home/javier/cardano/ouroboros-consensus/dist-newstyle/build/x86_64-linux/ghc-9.8.2/sop-extras-0.2.0.0/build/Data/SOP/Lenses.o, /home/javier/cardano/ouroboros-consensus/dist-newstyle/build/x86_64-linux/ghc-9.8.2/sop-extras-0.2.0.0/build/Data/SOP/Lenses.dyn_o )
[ 4 of 10] Compiling Data.SOP.NonEmpty ( src/Data/SOP/NonEmpty.hs, /home/javier/cardano/ouroboros-consensus/dist-newstyle/build/x86_64-linux/ghc-9.8.2/sop-extras-0.2.0.0/build/Data/SOP/NonEmpty.o, /home/javier/cardano/ouroboros-consensus/dist-newstyle/build/x86_64-linux/ghc-9.8.2/sop-extras-0.2.0.0/build/Data/SOP/NonEmpty.dyn_o )
[ 5 of 10] Compiling Data.SOP.InPairs ( src/Data/SOP/InPairs.hs, /home/javier/cardano/ouroboros-consensus/dist-newstyle/build/x86_64-linux/ghc-9.8.2/sop-extras-0.2.0.0/build/Data/SOP/InPairs.o, /home/javier/cardano/ouroboros-consensus/dist-newstyle/build/x86_64-linux/ghc-9.8.2/sop-extras-0.2.0.0/build/Data/SOP/InPairs.dyn_o )
[ 6 of 10] Compiling Data.SOP.Counting ( src/Data/SOP/Counting.hs, /home/javier/cardano/ouroboros-consensus/dist-newstyle/build/x86_64-linux/ghc-9.8.2/sop-extras-0.2.0.0/build/Data/SOP/Counting.o, /home/javier/cardano/ouroboros-consensus/dist-newstyle/build/x86_64-linux/ghc-9.8.2/sop-extras-0.2.0.0/build/Data/SOP/Counting.dyn_o )
[ 7 of 10] Compiling Data.SOP.OptNP   ( src/Data/SOP/OptNP.hs, /home/javier/cardano/ouroboros-consensus/dist-newstyle/build/x86_64-linux/ghc-9.8.2/sop-extras-0.2.0.0/build/Data/SOP/OptNP.o, /home/javier/cardano/ouroboros-consensus/dist-newstyle/build/x86_64-linux/ghc-9.8.2/sop-extras-0.2.0.0/build/Data/SOP/OptNP.dyn_o )
[ 8 of 10] Compiling Data.SOP.Tails   ( src/Data/SOP/Tails.hs, /home/javier/cardano/ouroboros-consensus/dist-newstyle/build/x86_64-linux/ghc-9.8.2/sop-extras-0.2.0.0/build/Data/SOP/Tails.o, /home/javier/cardano/ouroboros-consensus/dist-newstyle/build/x86_64-linux/ghc-9.8.2/sop-extras-0.2.0.0/build/Data/SOP/Tails.dyn_o )
[ 9 of 10] Compiling Data.SOP.Telescope ( src/Data/SOP/Telescope.hs, /home/javier/cardano/ouroboros-consensus/dist-newstyle/build/x86_64-linux/ghc-9.8.2/sop-extras-0.2.0.0/build/Data/SOP/Telescope.o, /home/javier/cardano/ouroboros-consensus/dist-newstyle/build/x86_64-linux/ghc-9.8.2/sop-extras-0.2.0.0/build/Data/SOP/Telescope.dyn_o )
[10 of 10] Compiling Data.SOP.Match   ( src/Data/SOP/Match.hs, /home/javier/cardano/ouroboros-consensus/dist-newstyle/build/x86_64-linux/ghc-9.8.2/sop-extras-0.2.0.0/build/Data/SOP/Match.o, /home/javier/cardano/ouroboros-consensus/dist-newstyle/build/x86_64-linux/ghc-9.8.2/sop-extras-0.2.0.0/build/Data/SOP/Match.dyn_o )
Error: [Cabal-7125]
Tests failed for test:doctest from ouroboros-consensus-0.18.0.0.

jasagredo avatar Jun 05 '24 11:06 jasagredo

I have not encountered this again, and no one else has. So let's close this issue.

jasagredo avatar Jul 09 '24 13:07 jasagredo

Saw Cabal-7125 twice today in 3.12.1.0, but the repo I was on is private, so I'm not sure if there's any useful information I can contribute.

stephen-smith avatar Jul 15 '24 15:07 stephen-smith

I'm pretty sure Cabal-7125 is for failed test-suite, nothing to do with the other error:

~\code\aa via λ 9.8.2 took 6s
➜ cabal test
Build profile: -w ghc-9.8.2 -O1
In order, the following will be built (use -v for more details):
 - aa-0.1.0.0 (test:aa-test) (first run)
Preprocessing test suite 'aa-test' for aa-0.1.0.0...
Building test suite 'aa-test' for aa-0.1.0.0...
[1 of 1] Compiling Main             ( test\Main.hs, C:\Users\Javier\code\aa\dist-newstyle\build\x86_64-windows\ghc-9.8.2\aa-0.1.0.0\t\aa-test\build\aa-test\aa-test-tmp\Main.o )
[2 of 2] Linking C:\\Users\\Javier\\code\\aa\\dist-newstyle\\build\\x86_64-windows\\ghc-9.8.2\\aa-0.1.0.0\\t\\aa-test\\build\\aa-test\\aa-test.exe
Running 1 test suites...
Test suite aa-test: RUNNING...
Test suite aa-test: FAIL
Test suite logged to:
C:\Users\Javier\code\aa\dist-newstyle\build\x86_64-windows\ghc-9.8.2\aa-0.1.0.0\t\aa-test\test\aa-0.1.0.0-aa-test.log
0 of 1 test suites (0 of 1 test cases) passed.
Error: [Cabal-7125]
Tests failed for test:aa-test from aa-0.1.0.0.


~\code\aa via λ 9.8.2 took 2s
❯ cat test/Main.hs
module Main (main) where

import System.Exit

main :: IO ()
main = exitFailure

jasagredo avatar Jul 15 '24 15:07 jasagredo

I was able to reproduce this error I started seeing again in my code. This is a minimal example:

❯ cat aa.cabal
cabal-version:      3.0
name:               aa
version:            0.1.0.0
license:            NONE
build-type:         Simple
extra-doc-files:    CHANGELOG.md
common warnings
    ghc-options: -Wall

library
    import:           warnings
    exposed-modules:  MyLib
    build-depends:    base, Agda
    hs-source-dirs:   src
    default-language: Haskell2010

test-suite bb-test
    import:           warnings
    default-language: Haskell2010
    type:             exitcode-stdio-1.0
    hs-source-dirs:   testbb
    main-is:          Main.hs
    build-depends:
        base, aa

test-suite aa-test
    import:           warnings
    default-language: Haskell2010
    type:             exitcode-stdio-1.0
    hs-source-dirs:   test
    main-is:          Main.hs
    build-depends:
        base

with the following files:

➜ tree
.
├── aa.cabal
├── app
│   └── Main.hs
├── cabal.project
├── CHANGELOG.md
├── src
│   └── MyLib.hs
├── test
│   └── Main.hs
└── testbb
    └── Main.hs

Note that aa-test doesn't depend on aa. I chose Agda because I wanted something that would make compilation for the library take more time than the test-suite building process. This is the outcome:

❯ cabal test all
Resolving dependencies...
Build profile: -w ghc-9.8.2 -O1
In order, the following will be built (use -v for more details):
 - QuickCheck-2.15.0.1 (lib) (requires build)
 - STMonadTrans-0.4.8 (lib) (requires download & build)
 - aa-0.1.0.0 (test:aa-test) (first run)
 - base-compat-0.14.0 (lib) (requires download & build)
 - blaze-builder-0.4.2.3 (lib) (requires build)
 - case-insensitive-1.2.1.0 (lib) (requires build)
 - data-hash-0.2.0.1 (lib) (requires download & build)
 - murmur-hash-0.1.0.10 (lib) (requires download & build)
 - parallel-3.2.2.0 (lib) (requires build)
 - peano-0.1.0.2 (lib) (requires download & build)
 - split-0.2.5 (lib) (requires build)
 - transformers-base-0.4.6 (lib) (requires build)
 - utf8-string-1.0.2 (lib) (requires build)
 - vector-hashtables-0.1.2.0 (lib) (requires download & build)
 - aeson-2.2.3.0 (lib) (requires build)
 - equivalence-0.4.1 (lib) (requires download & build)
 - gitrev-1.3.1 (lib) (requires download & build)
 - blaze-markup-0.8.3.0 (lib) (requires build)
 - boxes-0.1.5 (lib) (requires download & build)
 - monad-control-1.0.3.1 (lib) (requires build)
 - uri-encode-1.5.0.7 (lib) (requires download & build)
 - blaze-html-0.9.2.0 (lib) (requires build)
 - Agda-2.6.4.3 (lib:Agda) (requires download & build)
 - aa-0.1.0.0 (lib) (first run)
 - aa-0.1.0.0 (test:bb-test) (first run)
...
Preprocessing test suite 'aa-test' for aa-0.1.0.0...
Building test suite 'aa-test' for aa-0.1.0.0...
...
[1 of 1] Compiling Main             ( test\Main.hs, C:\Users\Javier\aa\dist-newstyle\build\x86_64-windows\ghc-9.8.2\aa-0.1.0.0\t\aa-test\build\aa-test\aa-test-tmp\Main.o )
...
[2 of 2] Linking C:\\Users\\Javier\\aa\\dist-newstyle\\build\\x86_64-windows\\ghc-9.8.2\\aa-0.1.0.0\\t\\aa-test\\build\\aa-test\\aa-test.exe
...
Error: [Cabal-9341]
Failed to find the installed unit 'aa-0.1.0.0-inplace' in package database stack.

jasagredo avatar Aug 06 '24 13:08 jasagredo

So, this looks like a regression in 3.12, correct?

ulysses4ever avatar Aug 06 '24 16:08 ulysses4ever

@ulysses4ever I think it is indeed a regression. It seems cabal build all && cabal test all is a workaround. I am surprised no-one else has faced this issue. If you run the example above do you get the same result?

jasagredo avatar Aug 07 '24 09:08 jasagredo

Thanks for the reproducer @jasagredo.

I took a look at this today. It seems that the problem is that cabal-install passes --coverage-for=aa-inplace... to the Cabal library invocation when compiling the aa-test component despite aa-test not depending on aa.

alt-romes avatar Aug 07 '24 15:08 alt-romes

Fix in #10250

alt-romes avatar Aug 07 '24 16:08 alt-romes

We are encountering this issue in the plutus repo, when running cabal test on a package following cabal clean. The workaround mentioned above - running cabal build all first - does work, but it's a bit inconvenient.

zliu41 avatar Sep 25 '24 02:09 zliu41