Skip to content

Package with custom Setup.hs "Encountered missing dependencies" #3199

Closed

Description

@eamsden

New report (edited by @ezyang)

Cabal 1.23 and later #2731 allow you to skip specifying dependencies which are not part of a buildable component. cabal-install was updated to take advantage of this fact.

However, when a package has a Custom setup script, it is possible for the Setup script to be built against an old version of Cabal, which is doesn't know to ignore non-buildable dependencies. In this case, cabal-install will pass an insufficient set of dependencies, resulting in an error like this:

    setup: At least the following dependencies are missing:
    process -any, temporary >=1.1

(where these are dependencies of non-buildable components.)

A workaround is to explicitly request that all components be built. For example, if there is some flag which must be selected to make a component buildable, you should pass --constraint="package-name +flagname"


Original bug report:

Trying to build pandoc-citeproc (which has a custom Setup.hs with a couple of hooks) using the latest-packaged version from git in the HVR repository (Version: 1.23+git20160204.0.7aab356~wily) fails to find dependencies already installed in a sandbox (whether the dependencies are installed manually or via the dependency solver).

$ uname -a
Linux <hostname> 4.2.0-30-generic #35-Ubuntu SMP Fri Feb 19 13:52:26 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.10.3
$ cabal --version
cabal-install version 1.23.0.0
compiled using version 1.23.1.0 of the Cabal library
$ cabal sandbox init
$ cabal install pandoc-citeproc
Configuring pandoc-citeproc-0.9...
setup: At least the following dependencies are missing:
process -any, temporary >=1.1
$ cabal sandbox hc-pkg list process
process-1.2.3.0
$ cabal sandbox hc-pkg list temporary
temporary-1.2.0.4

This was previously filed as jgm/pandoc-citeproc#216

Activity

  1. self-assigned this
    on Feb 29, 2016
  2. 23Skidoo commented on Feb 29, 2016

    @23Skidoo
    Member

    Thanks, will take a look. Probably fallout from setup-depends work.

  3. sebright commented on Mar 1, 2016

    @sebright
    Collaborator

    I think I see the problem. #2731 (merged in #3039) prevented cabal from requiring the dependencies of components that are not "Buildable". pandoc-citeproc has an executable, test-citeproc, that is enabled with the flag test_citeproc and depends on temporary and process. When cabal-1.23 solved for the dependencies, it chose -test_citeproc and didn't pass --dependency=temporary=... to Setup. Since Setup was built with Cabal < 1.23, Setup still required the dependencies of the non-buildable component and failed.

    I don't see an easy way to fix it before the release, besides reverting the cabal-install part of #2731.

  4. 23Skidoo commented on Mar 1, 2016

    @23Skidoo
    Member

    @GrayJay Thanks for the analysis. I think that the ultimate solution is to ensure that such a situation never happens and just always build setup scripts against the same version of Cabal that cabal-install was built with. The fact that a version mismatch can happen has been a never-ending source of bugs (see e.g. #3138).

    For the 1.24 release, maybe we can do something similar to the filterConfigureFlags approach and switch to the old solver behaviour when the Cabal version is too old?

  5. sebright commented on Mar 2, 2016

    @sebright
    Collaborator

    @23Skidoo I thought custom-setup allows cabal install to choose any versions of the library that are needed to build setup scripts, so we don't know what versions will be used until after solving. The backwards-compatible behavior would also need to be in the solver, since it involves choosing more dependencies. We could do something like first running the solver with a constraint on Cabal, and then solving without the constraint but with backwards-compatible behavior if the first run fails. Or we could decide package by package in the solver, maybe by adding a flag to each package with a custom-setup, but that seems like too much complexity.

    Is there any way to make Setup completely ignore dependencies? As far as I can tell, --exact-configuration only allows ignoring the version bounds.

  6. 23Skidoo commented on Mar 2, 2016

    @23Skidoo
    Member

    One other thing we can do is pass --constraint instead of --exact-configuration to setup scripts built with Cabal versions that don't support ignoring non-buildable components. This is probably the simplest solution.

    @GrayJay Yes, setup-depends with an upper bound on Cabal version present a problem. We may want to ban upper version bounds on Cabal, like we do for the cabal-version field (but allow them in post-release updates).

  7. sebright commented on Mar 2, 2016

    @sebright
    Collaborator

    @23Skidoo How can we use --constraint to ignore the dependencies?

  8. 23Skidoo commented on Mar 2, 2016

    @23Skidoo
    Member

    @GrayJay Before --exact-configuration was implemented, we used to feed solver output to Setup configure using the --constraint options: --constraint=foo-$VER_FOO --constraint=bar-$VER_BAR [...]. So I think that if we use that old interface, but only pass the constraints for dependencies of buildable components, Setup configure will be able to figure out what to do using its own solver.

  9. sebright commented on Mar 2, 2016

    @sebright
    Collaborator

    @23Skidoo I just tried configuring the package from the "Buildable" package test, and it didn't work:

    flag build-exe
      default: True
    
    library
    
    executable my-executable
      build-depends: base, unavailable-package
      main-is: Main.hs
      if !flag(build-exe)
        buildable: False
    
    $ ./Setup --version
    Cabal library version 1.22.4.0
    
    $ ./Setup configure --constraint='base==4.8.1.0' -f-build-exe
    Configuring BuildableField-0.1.0.0...
    Setup.exe: At least the following dependencies are missing:
    unavailable-package -any
    

    I think --constraint only adds to the constraints in the .cabal file.

  10. 23Skidoo commented on Mar 2, 2016

    @23Skidoo
    Member

    Well, that's a pity.

  11. 49 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Cabal: stanza/custom-setupcabal-install: v2-build systemtype: bug

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions