Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stack upload fails when using pvp-bounds and an if statement in my cabal file #2927

Closed
cdepillabout opened this issue Jan 15, 2017 · 6 comments

Comments

@cdepillabout
Copy link
Member

cdepillabout commented Jan 15, 2017

General summary/comments

stack upload fails when using pvp-bounds: both and an if statement in my cabal file.

Steps to reproduce

I am trying to upload the pretty-simple package to Hackage.

Here is how the bug can be reproduced:

  1. Clone pretty-simple
  2. Run stack upload .

You might need to edit the pretty-simple.cabal file so the package name is different. I'm not sure what will happen if you try to upload a package that conflicts with another package.

Expected

If I only use an if statements in my .cabal file (and not specify pvp-bounds: both in the stack.yaml file), then the upload succeeds.

If I only use pvp-bounds: both and don't use any if statements in my .cabal file, then the upload succeeds.

Actual

If I specify pvp-bounds: both and use an if statement in my .cabal file, then I get the following error:

$ stack upload --verbose .
Version 1.3.2 x86_64 hpack-0.15.0
2017-01-16 02:54:35.277167: [debug] Checking for project config at: /home/illabout/git/pretty-simple/stack.yaml
@(Stack/Config.hs:863:9)
2017-01-16 02:54:35.277412: [debug] Loading project config file stack.yaml
@(Stack/Config.hs:881:13)
2017-01-16 02:54:35.279167: [debug] Trying to decode /home/illabout/.stack/build-plan-cache/x86_64-linux/lts-7.13.cache
@(Data/Store/VersionTagged.hs:68:5)
2017-01-16 02:54:35.292025: [debug] Success decoding /home/illabout/.stack/build-plan-cache/x86_64-linux/lts-7.13.cache
@(Data/Store/VersionTagged.hs:72:13)
2017-01-16 02:54:35.296421: [debug] Run process: /sbin/ldconfig -p
@(System/Process/Read.hs:306:3)
2017-01-16 02:54:35.298242: [debug] Process finished in 1ms: /sbin/ldconfig -p
@(System/Process/Read.hs:306:3)
2017-01-16 02:54:35.298578: [debug] Run process: /usr/bin/gcc -v
@(System/Process/Read.hs:306:3)
2017-01-16 02:54:35.300258: [debug] Process finished in 1ms: /usr/bin/gcc -v
@(System/Process/Read.hs:306:3)
2017-01-16 02:54:35.300390: [debug] PIE enabled
@(Stack/Setup.hs:574:17)
2017-01-16 02:54:35.301051: [debug] Found shared library libtinfo.so.5 in /usr/lib
@(Stack/Setup.hs:563:38)
2017-01-16 02:54:35.301231: [debug] Found shared library libtinfo.so.6 in /usr/lib
@(Stack/Setup.hs:563:38)
2017-01-16 02:54:35.301331: [debug] Found shared library libncursesw.so.6 in 'ldconfig -p' output
@(Stack/Setup.hs:550:29)
2017-01-16 02:54:35.301419: [debug] Found shared library libgmp.so.10 in 'ldconfig -p' output
@(Stack/Setup.hs:550:29)
2017-01-16 02:54:35.301631: [debug] Did not find shared library libgmp.so.3
@(Stack/Setup.hs:564:38)
2017-01-16 02:54:35.301695: [debug] Using standard GHC build
@(Stack/Setup.hs:597:9)
2017-01-16 02:54:35.302050: [debug] Getting Cabal package version
@(Stack/GhcPkg.hs:189:5)
2017-01-16 02:54:35.302248: [debug] Run process: /home/illabout/.stack/programs/x86_64-linux/ghc-8.0.1/bin/ghc-pkg --no-user-package-db field --simple-output Cabal version
@(System/Process/Read.hs:306:3)
2017-01-16 02:54:35.303137: [debug] Getting global package database location
@(Stack/GhcPkg.hs:55:5)
2017-01-16 02:54:35.303268: [debug] Run process: /home/illabout/.stack/programs/x86_64-linux/ghc-8.0.1/bin/ghc-pkg --no-user-package-db list --global
@(System/Process/Read.hs:306:3)
2017-01-16 02:54:35.303842: [debug] Asking GHC for its version
@(Stack/Setup/Installed.hs:103:13)
2017-01-16 02:54:35.310539: [debug] Run process: /home/illabout/.stack/programs/x86_64-linux/ghc-8.0.1/bin/ghc --numeric-version
@(System/Process/Read.hs:306:3)
2017-01-16 02:54:35.337875: [debug] Process finished in 35ms: /home/illabout/.stack/programs/x86_64-linux/ghc-8.0.1/bin/ghc-pkg --no-user-package-db field --simple-output Cabal version
@(System/Process/Read.hs:306:3)
2017-01-16 02:54:35.339260: [debug] Process finished in 35ms: /home/illabout/.stack/programs/x86_64-linux/ghc-8.0.1/bin/ghc-pkg --no-user-package-db list --global
@(System/Process/Read.hs:306:3)
2017-01-16 02:54:35.344664: [debug] Process finished in 33ms: /home/illabout/.stack/programs/x86_64-linux/ghc-8.0.1/bin/ghc --numeric-version
@(System/Process/Read.hs:306:3)
2017-01-16 02:54:35.344888: [debug] Resolving package entries
@(Stack/Setup.hs:252:5)
2017-01-16 02:54:35.350968: [debug] Starting to execute command inside EnvConfig
@(Stack/Runners.hs:163:18)
2017-01-16 02:54:35.352952: [info] Getting file list for /home/illabout/git/pretty-simple/
@(Stack/SDist.hs:100:5)
2017-01-16 02:54:35.353300: [debug] Parsing the cabal files of the local packages
@(Stack/Build/Source.hs:298:5)
2017-01-16 02:54:35.355568: [debug] Parsing the targets
@(Stack/Build/Source.hs:235:5)
2017-01-16 02:54:35.356262: [debug] Start: getPackageFiles /home/illabout/git/pretty-simple/pretty-simple.cabal
@(Stack/Package.hs:250:21)
2017-01-16 02:54:35.372044: [debug] Finished in 15ms: getPackageFiles /home/illabout/git/pretty-simple/pretty-simple.cabal
@(Stack/Package.hs:250:21)
2017-01-16 02:54:35.373342: [debug] Getting global package database location
@(Stack/GhcPkg.hs:55:5)
2017-01-16 02:54:35.373604: [debug] Run process: /home/illabout/.stack/programs/x86_64-linux/ghc-8.0.1/bin/ghc-pkg --no-user-package-db list --global
@(System/Process/Read.hs:306:3)
2017-01-16 02:54:35.392414: [debug] Process finished in 18ms: /home/illabout/.stack/programs/x86_64-linux/ghc-8.0.1/bin/ghc-pkg --no-user-package-db list --global
@(System/Process/Read.hs:306:3)
2017-01-16 02:54:35.393241: [debug] Run process: /home/illabout/.stack/setup-exe-cache/x86_64-linux/Cabal-simple_mPHDZzAJ_1.24.0.0_ghc-8.0.1 --builddir=.stack-work/dist/x86_64-linux/Cabal-1.24.0.0 sdist --list-sources /tmp/stack-sdist10784/source-files-list
@(System/Process/Read.hs:340:3)
2017-01-16 02:54:35.441039: [debug] Process finished in 47ms: /home/illabout/.stack/setup-exe-cache/x86_64-linux/Cabal-simple_mPHDZzAJ_1.24.0.0_ghc-8.0.1 --builddir=.stack-work/dist/x86_64-linux/Cabal-1.24.0.0 sdist --list-sources /tmp/stack-sdist10784/source-files-list
@(System/Process/Read.hs:340:3)
2017-01-16 02:54:35.441460: [info] Building sdist tarball for /home/illabout/git/pretty-simple/
@(Stack/SDist.hs:102:5)
2017-01-16 02:54:35.443555: [debug] Parsing the cabal files of the local packages
@(Stack/Build/Source.hs:298:5)
2017-01-16 02:54:35.445360: [debug] Parsing the targets
@(Stack/Build/Source.hs:235:5)
2017-01-16 02:54:35.445712: [debug] Start: getPackageFiles /home/illabout/git/pretty-simple/pretty-simple.cabal
@(Stack/Package.hs:250:21)
2017-01-16 02:54:35.462078: [debug] Finished in 16ms: getPackageFiles /home/illabout/git/pretty-simple/pretty-simple.cabal
@(Stack/Package.hs:250:21)
2017-01-16 02:54:35.462753: [debug] Finding out which packages are already installed
@(Stack/Build/Installed.hs:68:5)
2017-01-16 02:54:35.462906: [debug] Run process: /home/illabout/.stack/programs/x86_64-linux/ghc-8.0.1/bin/ghc-pkg --global --no-user-package-db dump --expand-pkgroot
@(System/Process/Read.hs:306:3)
2017-01-16 02:54:35.488023: [debug] Process finished in 24ms: /home/illabout/.stack/programs/x86_64-linux/ghc-8.0.1/bin/ghc-pkg --global --no-user-package-db dump --expand-pkgroot
@(System/Process/Read.hs:306:3)
2017-01-16 02:54:35.497628: [debug] Ignoring package Cabal due to wanting version 1.24.2.0 instead of 1.24.0.0
@(Stack/Build/Installed.hs:191:5)
2017-01-16 02:54:35.497926: [debug] Run process: /home/illabout/.stack/programs/x86_64-linux/ghc-8.0.1/bin/ghc-pkg --user --no-user-package-db --package-db /home/illabout/.stack/snapshots/x86_64-linux/lts-7.13/8.0.1/pkgdb dump --expand-pkgroot
@(System/Process/Read.hs:306:3)
2017-01-16 02:54:35.541058: [debug] Process finished in 43ms: /home/illabout/.stack/programs/x86_64-linux/ghc-8.0.1/bin/ghc-pkg --user --no-user-package-db --package-db /home/illabout/.stack/snapshots/x86_64-linux/lts-7.13/8.0.1/pkgdb dump --expand-pkgroot
@(System/Process/Read.hs:306:3)
2017-01-16 02:54:35.541826: [debug] Run process: /home/illabout/.stack/programs/x86_64-linux/ghc-8.0.1/bin/ghc-pkg --user --no-user-package-db --package-db /home/illabout/git/pretty-simple/.stack-work/install/x86_64-linux/lts-7.13/8.0.1/pkgdb dump --expand-pkgroot
@(System/Process/Read.hs:306:3)
2017-01-16 02:54:35.561528: [debug] Process finished in 19ms: /home/illabout/.stack/programs/x86_64-linux/ghc-8.0.1/bin/ghc-pkg --user --no-user-package-db --package-db /home/illabout/git/pretty-simple/.stack-work/install/x86_64-linux/lts-7.13/8.0.1/pkgdb dump --expand-pkgroot
@(System/Process/Read.hs:306:3)
2017-01-16 02:54:35.561680: [debug] Ignoring package pretty-simple, from (InstalledTo Local,"/home/illabout/git/pretty-simple/.stack-work/install/x86_64-linux/lts-7.13/8.0.1/pkgdb/"), due to wanting version 1.0.0.6 instead of 1.0.0.5
@(Stack/Build/Installed.hs:191:5)
Unable to parse cabal file /tmp/stack10785/pretty-simple-1.0.0.6/pretty-simple.cabal: FromString "'then' branch of 'if' is empty" (Just 55)

The very last line seems to be the culprit:

Unable to parse cabal file /tmp/stack10785/pretty-simple-1.0.0.6/pretty-simple.cabal: FromString "'then' branch of 'if' is empty" (Just 55)

This error is about the following executable section in the cabal file:

executable pretty-simple-example
  main-is:             Example.hs
  other-modules:       Example.Data
  hs-source-dirs:      example
  build-depends:       base
                     , pretty-simple
  default-language:    Haskell2010
  ghc-options:         -Wall -threaded -rtsopts -with-rtsopts=-N

  if flag(buildexample)
    buildable:       True
  else
    buildable:       False

The error looks like it is saying that there is no then branch of the if statement, but as far as I can tell, there is a then branch.

Stack version

$ stack --version
Version 1.3.2 x86_64 hpack-0.15.0

Method of installation

  • stack upgrade
@cdepillabout
Copy link
Member Author

This bug was noticed because of the following PR: cdepillabout/pretty-simple#1

@mgsloan
Copy link
Contributor

mgsloan commented Feb 1, 2017

Hmm, I can't directly reproduce the issue. With upload it does indeed try to upload. I can also create a --pvp-bounds tarball:

mgsloan@computer:~/fpco/test-stack/issue2927/pretty-simple$ stack sdist --pvp-bounds both
Getting file list for /home/mgsloan/fpco/test-stack/issue2927/pretty-simple/
Building sdist tarball for /home/mgsloan/fpco/test-stack/issue2927/pretty-simple/
Checking package 'pretty-simple' for common mistakes
Wrote sdist tarball to /home/mgsloan/fpco/test-stack/issue2927/pretty-simple/.stack-work/dist/x86_64-linux/Cabal-1.24.0.0/pretty-simple-2.0.0.0.tar.gz

The resulting cabal file does look a bit different for that stanza

   if !flag(buildexample)
       buildable: False
   main-is: Example.hs
   build-depends:
       base >=4.9.0.0 && <4.10,
       pretty-simple >=2.0.0.0 && <2.1
   default-language: Haskell2010
   hs-source-dirs: example
   other-modules:
       Example.Data
   ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N

Seems like cabal is doing some simplification?

@cdepillabout
Copy link
Member Author

@mgsloan Thanks for looking into this.

That's really strange. I'm still getting the same error on the same repo. Here's how I'm reproducing this:

$ stack --version
Version 1.3.2 x86_64 hpack-0.15.0
$ git clone [email protected]:cdepillabout/pretty-simple.git
$ cd pretty-simple
$ git checkout v2.0.0.0
$ stack sdist --pvp-bounds both
Getting file list for /home/me/git/pretty-simple-test/
Building sdist tarball for /home/me/git/pretty-simple-test/
Unable to parse cabal file /tmp/stack20626/pretty-simple-2.0.0.0/pretty-simple.cabal: FromString "'then' branch of 'if' is empty" (Just 53)

If we're using the same version of stack, what could cause me to have this issue and you not to have this issue?

@mgsloan
Copy link
Contributor

mgsloan commented Feb 2, 2017

Actually, I'm on the latest git version of stack, which I believe includes a newer version of the Cabal library than v1.3.2. Can you give stack upgrade --git a try and see if that resolves things?

@cdepillabout
Copy link
Member Author

stack upgrade --git didn't seem to do anything for me:

$ stack upgrade --git
Current Stack version: 1.3.2, available download version: 1.3.2
Skipping binary upgrade, your version is already more recent
$

Maybe you meant for me to try the latest master?

I tried it with the latest master for stack and it seemed to work!

$ stack --version
Version 1.3.3, Git revision aae28fe5929af966e36b5ad075d455087a255b30 (4527 commits) x86_64 hpack-0.17.0
$ git clone [email protected]:cdepillabout/pretty-simple.git
$ cd pretty-simple
$ git checkout v2.0.0.0
$ stack sdist --pvp-bounds both
Getting file list for /home/me/git/pretty-simple-test/
Building sdist tarball for /home/me/git/pretty-simple-test/
Checking package 'pretty-simple' for common mistakes
Wrote sdist tarball to /home/me/git/pretty-simple/.stack-work/dist/x86_64-linux/Cabal-1.24.0.0/pretty-simple-2.0.0.0.tar.gz

So I guess this has been fixed by a newer version of the Cabal library! Thanks for working with me on this!

@mgsloan
Copy link
Contributor

mgsloan commented Feb 3, 2017

Cool! I'm surprised that stack upgrade --git no longer works - split off #2977

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants