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

cabal.project parser ignores the last package if it doesn't end in newline #186

Open
Tracked by #307
srid opened this issue Jul 26, 2023 · 4 comments
Open
Tracked by #307
Labels
bug Something isn't working

Comments

@srid
Copy link
Owner

srid commented Jul 26, 2023

No description provided.

@srid srid added the bug Something isn't working label Jul 26, 2023
@ParetoOptimalDev
Copy link

ParetoOptimalDev commented Jul 26, 2023

This seems to happen with a leading newline too:

packages:
  . 

  # some comment
   another-package

@srid
Copy link
Owner Author

srid commented Jul 26, 2023

<rant>
If only the cabal ecosystem had gone with JSON/TOML, like Rust Cargo does, rather than re-inventing their own formats ...
</rant>

@andreasabel
Copy link

In a cabal.project file, packages: foo is perfectly valid, but not recognized by a parser that insists that packages: is followed by a newline character:

key = parsec.string "packages:\n";

Also packages: foo bar is valid syntax, which isn't recognized by a parser that insists on newline characters between package names.

val =
parsec.many1
(parsec.between spaces1 newline path);

In the wild:
https://github.com/tree-sitter/haskell-tree-sitter/blob/387494ab7f4efd9f4d3cdbf8e60ed55bc1f1688a/cabal.project

The official parser is implemented here: https://github.com/haskell/cabal/blob/84acb0e9510c82caae1c1bc4397aafca7f25f83a/cabal-install/src/Distribution/Client/ProjectConfig/Legacy.hs#L1207-L1210
https://github.com/haskell/cabal/blob/84acb0e9510c82caae1c1bc4397aafca7f25f83a/cabal-install/src/Distribution/Client/ProjectConfig/Legacy.hs#L1239-L1273
Yeah, that's a mouthful... agree to the rant. Maybe a tool like https://hackage.haskell.org/package/cabal2json could help (if it was maintained).

@roberth
Copy link
Collaborator

roberth commented Aug 21, 2023

Part of the reason to reimplement it in Nix is to avoid "import from derivation", making it so that the flake attributes can be determined without doing any builds. It keeps things like nix build shell completions fast, among other benefits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants