haskell / haskell/cabal

`cabal new-haddock` regression (setup: internal error when calculating transitive package dependencies.)

Open
#5,423 13 comments 0 reactions 0 assignees View on GitHub
cabal-install: cmd/haddock cabal-install: custom type: regression
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

I originally noticed this issue when trying to [upgrade `singletons`' Travis setup](https://travis-ci.org/goldfirere/singletons/jobs/402254201#L4238) to use `cabal-install-head`. That is:

```
$ /opt/cabal/head/bin/cabal --version
cabal-install version 2.3.0.0
compiled using version 2.3.0.0 of the Cabal library
```

I've prepared a more minimal reproduction at https://github.com/RyanGlScott/cabal-gh5423. To reproduce the issue, do the following:

```
$ git clone https://github.com/RyanGlScott/cabal-gh5423
$ cd cabal-gh5423/
$ /opt/cabal/head/bin/cabal new-haddock cabal-gh5423:tests
Resolving dependencies...
Build profile: -w ghc-8.4.3 -O1
In order, the following will be built (use -v for more details):
- cabal-gh5423-0.1 (first run)
[1 of 1] Compiling Main ( /home/rgscott/Documents/Hacking/Haskell/cabal-gh5423/dist-newstyle/build/x86_64-linux/ghc-8.4.3/cabal-gh5423-0.1/setup/setup.hs, /home/rgscott/Documents/Hacking/Haskell/cabal-gh5423/dist-newstyle/build/x86_64-linux/ghc-8.4.3/cabal-gh5423-0.1/setup/Main.o )
Linking /home/rgscott/Documents/Hacking/Haskell/cabal-gh5423/dist-newstyle/build/x86_64-linux/ghc-8.4.3/cabal-gh5423-0.1/setup/setup ...
Configuring cabal-gh5423-0.1...
Found dependency closure
Preprocessing library for cabal-gh5423-0.1..
Running Haddock on library for cabal-gh5423-0.1..
Haddock coverage:
0% ( 0 / 1) in 'CabalSandbox'
Missing documentation for:
Module header
Documentation created:
/home/rgscott/Documents/Hacking/Haskell/cabal-gh5423/dist-newstyle/build/x86_64-linux/ghc-8.4.3/cabal-gh5423-0.1/doc/html/cabal-gh5423/index.html
Preprocessing test suite 'cabal-gh5423-tests' for cabal-gh5423-0.1..
Running Haddock on test suite 'cabal-gh5423-tests' for cabal-gh5423-0.1..
setup: internal error when calculating transitive package dependencies.
Debug info: []

cabal: Failed to build documentation for cabal-gh5423-0.1.
```

`cabal-gh5423` is a package with a library, test suite, and `custom-setup` script that looks like:

```haskell
module Main (main) where

import Distribution.PackageDescription
import Distribution.Simple
import Distribution.Simple.LocalBuildInfo
import Distribution.Simple.PackageIndex

main :: IO ()
main = defaultMainWithHooks simpleUserHooks
{ haddockHook = \pkg lbi hooks flags -> do
blah pkg lbi
haddockHook simpleUserHooks pkg lbi hooks flags
}

blah :: PackageDescription -> LocalBuildInfo -> IO ()
blah pkg lbi =
withLibLBI pkg lbi $ \_ libCLBI -> do
let libDeps = map fst $ componentPackageDeps libCLBI
case dependencyClosure (installedPkgs lbi) libDeps of
Left p -> p `seq` putStrLn "Found dependency closure"
Right _ -> error "Broken dependency closure"
```

(In reality, `singletons` actually uses the computed dependency closure for something useful, but I've elided this for the sake of keeping things simple.)

Contributor guide

Open the contributing guide

Research direction

Clone the linked cabal-gh5423 reproduction and run the shown cabal new-haddock command first. Inspect its custom-setup setup.hs, especially haddockHook and the dependencyClosure call; done means documentation generation completes for the test suite without the internal transitive-dependency error.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.