haskell / haskell/cabal

cabal.project file format is sensitive to trailing whitespace

Open
#10,957 0 comments 0 reactions 0 assignees View on GitHub
needs triage type: bug
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

**Describe the bug**
Whitespace at the end of a line in a cabal.project file is parsed as part of the value it's attached to.

**To Reproduce**

```
[b@kuusi:~/tmp/aoeu]$ cabal init --non-interactive --exe proj
[Info] Guessing dependencies...
[Info] Using cabal specification: 3.12
[Warn] unknown license type, you must put a copy in LICENSE yourself.
[Info] Creating fresh file CHANGELOG.md...
[Info] Creating fresh directory ./app...
[Info] Creating fresh file app/Main.hs...
[Info] Creating fresh file proj.cabal...
[Warn] No synopsis given. You should edit the .cabal file and add one.
[Info] You may want to edit the .cabal file and add a Description field.

[b@kuusi:~/tmp/aoeu]$ cat > cabal.project
packages: proj
static: True

[b@kuusi:~/tmp/aoeu]$ cabal build proj
Error: [Cabal-7090]
Error parsing project file /home/b/tmp/aoeu/cabal.project:2:
Parse of field 'static' failed (True ): True

```

**Expected behavior**
The line `static: True ` shouldn't cause a failure, because the trailing whitespace shouldn't be parsed as part of the field's value.

**System information**
- NixOS

```
$ cabal -V
cabal-install version 3.12.1.0
compiled using version 3.12.1.0 of the Cabal library
```

**Additional context**

#10954 , #10951

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with the shown cabal.project contents and running `cabal build proj`. Trace the project-file parser for the `static` field and inspect related issues #10954 and #10951. Done means trailing whitespace is ignored so `static: True ` parses successfully, with regression coverage for the case.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.