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

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

Open
cartazio opened this issue Feb 24, 2021 · 8 comments

Comments

@cartazio
Copy link
Contributor

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
Copy link
Member

fgaz commented Feb 24, 2021

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
Copy link
Contributor Author

cartazio commented Feb 24, 2021 via email

@fgaz
Copy link
Member

fgaz commented Feb 24, 2021

@emilypi
Copy link
Member

emilypi commented Feb 24, 2021

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
Copy link
Contributor Author

cartazio commented Feb 24, 2021 via email

@fgaz
Copy link
Member

fgaz commented Feb 24, 2021

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
Copy link
Contributor Author

cartazio commented Feb 24, 2021 via email

@emilypi
Copy link
Member

emilypi commented Feb 24, 2021

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 :)

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

No branches or pull requests

3 participants