Skip to content

stack sdist (2.3.1) generates weird PVP bounds in .cabal file #5289

Closed
@vaclavsvejcar

Description

@vaclavsvejcar

General summary/comments (optional)

For my haskell project I use stack for building & generating tarball for Hackage. To generate PVP bounds in resulting .cabal file, I use the pvp-bounds: lower option in my stack.yaml. Everything worked fine with stack-2.1.3, but after upgrading to stack-2-3-1, running stack sdist results in following error:

Unable to parse cabal file from package /private/var/folders/fl/g3lf6zg14d7_5n2_rvs7ntgw0000gn/T/stack-450c73176363635d/headroom-0.2.2.0/headroom.cabal

- 147:17: 
unexpected Sublibrary dependency syntax used. To use this syntax the package needs to specify at least 'cabal-version: 3.0'. Alternatively, if you are depending on an internal library, you can write directly the library name as it were a package.
expecting space

When checking the generated .cabal file, I noticed that version bounds in dependencies section looks like this:

    build-depends:
        aeson : {} >=1.4.7.1,
        base : {} >=4.7 && <5,
        either : {} >=5.0.1.1,
        file-embed : {} >=0.0.11.2,

Note the {} which probably causes the issue. I tried to use Cabal 3 as suggested by changing several things in my package.yaml file gist, which suppresed all the warnings, but these {} remains in the generated .cabal file inside the distribution tarball. When trying to upload such tar to Hackage, it ends up with following error:

Invalid package

headroom-0.2.2.0/headroom.cabal:148:15: unexpected ':' expecting space, white space, opening paren, operator, comma or end of input aeson : {} >=1.4.7.1, base : {} >=4.7 && <5, either : {} >=5.0.1.1, file-embed : {} >=0.0.11.2, mustache : {} >=2.3.1, optparse-applicative : {} >=0.15.1.0, pcre-light : {} >=0.4.1.0, rio : {} >=0.1.15.1, template-haskell : {} >=2.15.0.0, time : {} >=1.9.3, yaml : {} >=0.11.3.0

Is this expected behaviour, or is it either stack or hpack bug or error in my configuration? Either way, I'm not able to generate valid distribution tarball for Hackage using stack-2.3.1.

Steps to reproduce

For example:

  1. Clone https://github.com/vaclavsvejcar/headroom
  2. Run stack sdist inside the project directory

Expected

.tar.gz distribution file that would be accepted by Hackage (as with stack-2.1.3)

Actual

Generated .tar.gz contains (probably) invalid syntax in .cabal file.

Stack version

$ stack --version
Version 2.3.1, Git revision de2a7b694f07de7e6cf17f8c92338c16286b2878 (8103 commits) x86_64 hpack-0.33.0

Method of installation

  • Official binary, downloaded from stackage.org or fpcomplete's package repository

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions