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.
For example:
stack sdist inside the project directory.tar.gz distribution file that would be accepted by Hackage (as with stack-2.1.3)
Generated .tar.gz contains (probably) invalid syntax in .cabal file.
$ stack --version
Version 2.3.1, Git revision de2a7b694f07de7e6cf17f8c92338c16286b2878 (8103 commits) x86_64 hpack-0.33.0
Affects me too, I'll have to rollback to the older stack to publish new package.
@snoyberg Can you please confirm whether this is intended behaviour or bug and in case of bug, it it's problem of _stack_ or rather _hpack_? Have no idea what causes this, but it's pretty unfortunate as I'm unable to generate working _tarball_ with stack sdist using current version of _stack_.
Most likely it's a big in the Cabal library. We use its pretty printer, and it's been buggy in the past. I'd recommend turning off the pvp-bounds option. Due to these kinds of Cabal bugs, I've considered removing the feature
The issue is in how stack uses the Cabal library – please see the PR #5309 linked above for the fix.
Most helpful comment
The issue is in how stack uses the Cabal library – please see the PR #5309 linked above for the fix.