haskell / cabal

Official upstream development repository for Cabal and cabal-install
https://haskell.org/cabal
Other
1.63k stars 695 forks source link

cabal 3.6 does not accept a cabal-version of 3.4, 3.0 #7644

Closed ivanperez-keera closed 3 years ago

ivanperez-keera commented 3 years ago

Describe the bug I'm trying to install a package that uses bnfc as a build tool, declared using build-tool-depends. I want to depend on the executable spefically, so I use the syntax BNFC:bnfc. Consequently, I've bumped the cabal-version: field to 3.0.

With cabal-install 3.4, the above works. With cabal-install 3.6, that gives me an error message like this (see also https://github.com/haskell/cabal/issues/7154):

Errors encountered when parsing cabal file backend/backend.cabal:

backend/backend.cabal:0:0: error:
Unsupported cabal-version. See https://github.com/haskell/cabal/issues/4899.

To Reproduce

  1. Install cabal-install 3.6 on a mac.
  2. Try to install a package that specifies a cabal-version: of 3.0 or greater. (I've tried 3.4, 3.0, 3.6).

Expected behavior I expected cabal to tell me:

  1. which versions would be valid.
  2. if there is a parsing error, what the parsing error really is (where it was, what it found, what it expected).

System information

Additional context Some of the packages have a custom setup. It's been detailed here:

https://github.com/haskell/cabal/issues/6726#issuecomment-918663262

gbaz commented 3 years ago

I just tested this and it works, there appears to be something wrong with your cabal file? Note that the error should specify what the version is, unless there is a parsing error. I.e. cabal-version: 3.8 will correctly throw, but the error it gives is:

foo.cabal:0:0: error:
Unsupported cabal-version 3.8. See https://github.com/haskell/cabal/issues/4899.
ivanperez-keera commented 3 years ago

Cabal check reports no errors.

ivanperez-keera commented 3 years ago

It gives no indication of the version number. There may be a parsing error, but it also shows no line-column, no indication of which versions it expects, or what it (thinks it) found.

gbaz commented 3 years ago

You’ll need to post a repro because, again, I just tested using a fresh cabal install 3.6 via ghcup on a mac, and it worked just fine.

jneira commented 3 years ago

I would say it is a bug which needs to be reproduced and not a question (if we found it is not such a bug we could close it).

Mikolaj commented 3 years ago

There may be a parsing error, but it also shows no line-column, no indication of which versions it expects, or what it (thinks it) found.

I'd guess it shows line-column (0, 0) and it's correct if the problem is version number, which is always the first in the file.

That it doesn't show what it got either indicates you had version-number: with the empty string as value or that you were using quite an old cabal (I guess, around the date 3.4 was released):

https://github.com/haskell/cabal/blame/26b2defed53c6ee8131bbf117020506a7c1c4a11/Cabal/Distribution/PackageDescription/Parsec.hs#L109

Anyway, @ivanperez-keera, given that you share in various places that 3.6 is buggy and should not replace 3.4, could we focus on reproducing this problem so that either we can quickly publish a fixed version or you can quickly revert your statement or, in the worst case, we can publicly announce that indeed, 3.6 should be avoided until we fix it?

Edited: changed last 'you' to 'we'.

Edit2: actually, I've ruled the first case out. With empty field I'm getting:

unexpected end of input
ivanperez-keera commented 3 years ago

I'm working on giving you a minimal reproducible example (but I have a few things on today, just normal busy). I'll send it ASAP.

This error was with cabal-install 3.6 (on a Mac). Files with cabal-version: 3.0 work with cabal-install 3.4 (on Ubuntu).

EDIT: clarification of what works and what doesn't.

Mikolaj commented 3 years ago

BTW, @ivanperez-keera, it appears you were right 3.6 is not quit ready: https://github.com/haskell/cabal/issues/7649#issuecomment-919495386. All the more reason to try to reproduce ASAP to get the fix, if any, to 3.6.2.

phadej commented 3 years ago

@Mikolaj this issue is on mac, so Windows issue is not related (that would be very very weird).

Mikolaj commented 3 years ago

Sure, I meant, given that quick 3.6.2 is almost guaranteed, we need to gather all unrelated quickfixes fast.

emilypi commented 3 years ago

I can't repro this on my MBP Big Sur.

With cabal-version: 3.0:

λ p foobar → uname -a
Darwin p.lan 20.2.0 Darwin Kernel Version 20.2.0: Wed Dec  2 20:39:59 PST 2020; root:xnu-7195.60.75~1/RELEASE_X86_64 x86_64
λ p foobar → cabal --version
cabal-install version 3.6.0.0
compiled using version 3.6.1.0 of the Cabal library
λ p foobar → cabal init -i
Should I generate a simple project with sensible defaults? [default: y] n
What does the package build:
   1) Executable
   2) Library
   3) Library and Executable
Your choice? 2
Please choose version of the Cabal specification to use:
   1) 1.10   (legacy)
   2) 2.0    (+ support for Backpack, internal sub-libs, '^>=' operator)
   3) 2.2    (+ support for 'common', 'elif', redundant commas, SPDX)
 * 4) 2.4    (+ support for '**' globbing)
   5) 3.0    (+ set notation for ==, common stanzas in ifs, more redundant commas, better pkgconfig-depends)
Your choice? [default: 2.4    (+ support for '**' globbing)] 
Package name? [default: foobar] ^C
λ p foobar → cabal init -i
Should I generate a simple project with sensible defaults? [default: y] n
What does the package build:
   1) Executable
   2) Library
   3) Library and Executable
Your choice? 2
Please choose version of the Cabal specification to use:
   1) 1.10   (legacy)
   2) 2.0    (+ support for Backpack, internal sub-libs, '^>=' operator)
   3) 2.2    (+ support for 'common', 'elif', redundant commas, SPDX)
 * 4) 2.4    (+ support for '**' globbing)
   5) 3.0    (+ set notation for ==, common stanzas in ifs, more redundant commas, better pkgconfig-depends)
Your choice? [default: 2.4    (+ support for '**' globbing)] 5
Package name? [default: foobar] 
The name foobar is already in use by another package on Hackage. Do you want to choose a different name? [default: y] n
Package version? [default: 0.1.0.0] 
Please choose a license:
 * 1) NONE
   2) BSD-2-Clause
   3) BSD-3-Clause
   4) Apache-2.0
   5) MIT
   6) MPL-2.0
   7) ISC
   8) GPL-2.0-only
   9) GPL-3.0-only
  10) LGPL-2.1-only
  11) LGPL-3.0-only
  12) AGPL-3.0-only
  13) GPL-2.0-or-later
  14) GPL-3.0-or-later
  15) LGPL-2.1-or-later
  16) LGPL-3.0-or-later
  17) AGPL-3.0-or-later
  18) Other (specify)
Your choice? [default: NONE] 3
Author name? [default: Emily Pillmore] 
Maintainer email? [default: emilypi@cohomolo.gy] 
Project homepage URL? 
Project synopsis? 
Project category:
 * 1) (none)
   2) Codec
   3) Concurrency
   4) Control
   5) Data
   6) Database
   7) Development
   8) Distribution
   9) Game
  10) Graphics
  11) Language
  12) Math
  13) Network
  14) Sound
  15) System
  16) Testing
  17) Text
  18) Web
  19) Other (specify)
Your choice? [default: (none)] 
Library source directory:
 * 1) src
   2) lib
   3) src-lib
   4) (none)
   5) Other (specify)
Your choice? [default: src] 
Should I generate a test suite for the library? [default: y] n
What base language is the package written in:
 * 1) Haskell2010
   2) Haskell98
   3) Other (specify)
Your choice? [default: Haskell2010] 
Add informative comments to each field in the cabal file (y/n)? [default: n] n

Guessing dependencies...

Generating LICENSE...
Generating CHANGELOG.md...
Generating src/MyLib.hs...
Generating foobar.cabal...

Warning: no synopsis given. You should edit the .cabal file and add one.
You may want to edit the .cabal file and add a Description field.
λ p foobar → cabal build
Resolving dependencies...
Build profile: -w ghc-8.10.4 -O1
In order, the following will be built (use -v for more details):
 - foobar-0.1.0.0 (lib) (first run)
Configuring library for foobar-0.1.0.0..
Preprocessing library for foobar-0.1.0.0..
Building library for foobar-0.1.0.0..
[1 of 1] Compiling MyLib            ( src/MyLib.hs, /Users/emilypi/kadena/foobar/dist-newstyle/build/x86_64-osx/ghc-8.10.4/foobar-0.1.0.0/build/MyLib.o, /Users/emilypi/kadena/foobar/dist-newstyle/build/x86_64-osx/ghc-8.10.4/foobar-0.1.0.0/build/MyLib.dyn_o )
λ p foobar → 

with cabal-version: 3.4:

λ p foobar → cabal build
Resolving dependencies...
Build profile: -w ghc-8.10.4 -O1
In order, the following will be built (use -v for more details):
 - foobar-0.1.0.0 (lib) (configuration changed)
Configuring library for foobar-0.1.0.0..
Preprocessing library for foobar-0.1.0.0..
Building library for foobar-0.1.0.0..

And with cabal-version: 3.6:

λ p foobar → cabal build      
Resolving dependencies...
Build profile: -w ghc-8.10.4 -O1
In order, the following will be built (use -v for more details):
 - foobar-0.1.0.0 (lib) (configuration changed)
Configuring library for foobar-0.1.0.0..
Preprocessing library for foobar-0.1.0.0..
Building library for foobar-0.1.0.0..

Bonus with cabal-version: 3.6 and a dep on BNFC:bnfc in build-tool-depends:

λ p foobar → cabal build      
Resolving dependencies...
Build profile: -w ghc-8.10.4 -O1
In order, the following will be built (use -v for more details):
 - BNFC-2.9.2 (exe:BNFC) (requires download & build)
 - foobar-0.1.0.0 (lib) (configuration changed)
Downloading  BNFC-2.9.2
Downloaded   BNFC-2.9.2
Starting     BNFC-2.9.2 (all, legacy fallback)
Building     BNFC-2.9.2 (all, legacy fallback)
Installing   BNFC-2.9.2 (all, legacy fallback)
Completed    BNFC-2.9.2 (all, legacy fallback)
Configuring library for foobar-0.1.0.0..
Preprocessing library for foobar-0.1.0.0..
Building library for foobar-0.1.0.0..
emilypi commented 3 years ago

@ivan-m can you give me an idea of what cabal is being used for this? I notice you didn't give a version, except what you think you're using, but the simplest explanation in this case is perhaps PATH shadowing. Maybe there's a stale old cabal executable being referenced somewhere in your PATH

ivan-m commented 3 years ago

Hi @emilypi,

Do you mean @ivanperez-keera ?

Mikolaj commented 3 years ago

Hi @ivan-m! Long time no see. :) Yes, I'm sure that's exactly the typo.

emilypi commented 3 years ago

ack yeah sorry @ivan-m i meant @ivanperez-keera

Mikolaj commented 3 years ago

@ivanperez-keera: I'm assuming you can't reproduce this either. If so, I'm going to close this. Thank you for the report.

jneira commented 3 years ago

@ivanperez-keera feel free to reopen if you experience it again, thanks