haskell / cabal

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

config section in ~/.cabal/config for the init workflow crashes when specifying newer cabal versions #7300

Open cartazio opened 3 years ago

cartazio commented 3 years ago

config section in ~/.cabal/config for the init workflow crashes when specifying newer cabal versions

this is fine

init
  interactive: True
  -- cabal-version: 2.4
  -- license:
  -- tests:
  -- test-dir:
  -- language: Haskell2010
  -- application-dir: app
  -- source-dir: src

this is not

init
  interactive: True
  cabal-version: 3.2
  -- license:
  -- tests:
  -- test-dir:
  language: Haskell2010
  application-dir: app
  source-dir: src

yields this error

cabal: Error parsing config file /Users/wrn6115/.cabal/config:141:
Parse of field 'cabal-version' failed (Cannot parse Cabal specification
version: 3.2): 3.2
fgaz commented 3 years ago

cabal-version 3.2 doesn't exist. the error could be nicer though (Cannot parse Cabal specification version: 3.2, this version doesn't exist, check this url...).

Did cabal generate that section? That would be a bug

cartazio commented 3 years ago

Nope. I wanted to specify a version in the 3.x series and made one up.

What version values does this config suport?

On Wed, Feb 24, 2021 at 11:29 AM Francesco Gazzetta < notifications@github.com> wrote:

cabal-version 3.2 doesn't exist https://cabal.readthedocs.io/en/3.4/file-format-changelog.html. the error could be nicer though (Cannot parse Cabal specification version: 3.2, this version doesn't exist, check this url...).

Did cabal generate that section? That would be a bug

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/haskell/cabal/issues/7300#issuecomment-785200078, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAABBQVRMENY7AHE3AVAOOTTAUSNFANCNFSM4YEYB7ZQ .

fgaz commented 3 years ago

https://cabal.readthedocs.io/en/latest/file-format-changelog.html

emilypi commented 3 years ago

Just to reiterate my suggestion here:

cabal-version describes a version spec, which makes the flag slightly misleading. I would propose two possible solutions:

  1. we look at calling this cabal-spec in the future, so as to avoid confusion. This is a bit of a deep change, I"m not sure if i want to go down this route.
  2. we change the parser to locate a least upper spec bound for valid cabal versions. No code really has to change besides the additional parsing cases.

It is a rough edge as is. If it's tripping up power users like Carter, it's tripping up everyone else too.

cartazio commented 3 years ago

Even simply an enumeration of allowed spec versions and url for further reading would be helpful

On Wed, Feb 24, 2021 at 12:26 PM Emily Pillmore notifications@github.com wrote:

Just to reiterate my suggestion here:

cabal-version describes a version spec, which makes the flag slightly misleading. I would propose two possible solutions:

  1. we look at calling this cabal-spec in the future, so as not to avoid confusion. This is a bit of a deep change, I"m not sure if i want to go down this route.
  2. we change the parser to locate a least upper spec bound for valid cabal versions. No code really has to change besides the additional parsing cases.

It is a rough edge as is. If it's tripping up power users like Carter, it's tripping up everyone else too.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/haskell/cabal/issues/7300#issuecomment-785241596, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAABBQU2NCT2AXED6LOJADDTAUZFPANCNFSM4YEYB7ZQ .

fgaz commented 3 years ago

Yeah, I think this is one of those cases where just a better error message goes a long way. @emilypi's second option is clever though

cartazio commented 3 years ago

In the latter case, a warning and the change suggestion/ reading ref would still be nice.

On Wed, Feb 24, 2021 at 3:06 PM Francesco Gazzetta notifications@github.com wrote:

Yeah, I think this is one of those cases where just a better error message goes a long way. @emilypi https://github.com/emilypi's second option is clever though

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/haskell/cabal/issues/7300#issuecomment-785339674, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAABBQRGX4YYTSGCH53GPXTTAVL55ANCNFSM4YEYB7ZQ .

emilypi commented 3 years ago

Yeah, a warning blurb e.g. like

Warning: `cabal-version 3.2` defaults to the 3.0 parser specification. To remove these warnings, please set `cabal-version: 3.0` in your `.cabal` file.

Or something. I'm not a writer :)