haskell / haskell/cabal

user-config --augment ignores indented lines

Open
#9,040 0 comments 0 reactions 0 assignees View on GitHub
cabal-install: cmd/user-config
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

**Describe the bug**
When providing configuration overrides to `cabal user-config`, it is possible to specify indented lines, provided their (unindented) parent is also specified. This is true both for overriding existing config files, and for the --augment flag.

When providing unindented lines, the result of the merge will (correctly) use the values supplied to `--augment`, rather than using the remote defaults.

When providing indented lines, the result of the merge will (incorrectly) use the remote defaults, ignoring the `--augment` values.

**To Reproduce**
``` bash
# Reproduction A
$ cabal user-config update -a "
program-default-options
ghc-options: -dynamic"
$ grep " ghc-options" ~/.cabal/config
```

``` bash
# Reproduction B
$ cat << EOF > ~/.cabal/config
program-default-options
ghc-options: -dynamic
EOF
$ cabal user-config update
$ grep " ghc-options" ~/.cabal/config
```

``` bash
# Reproduction C
$ rm -f ~/.cabal/config
$ cabal user-config init -a "
program-default-options
ghc-options: -dynamic"
$ grep " ghc-options" ~/.cabal/config
```

**Expected behavior**
the following line is present in `~/.cabal/config`:
```
ghc-options: -dynamic
```

**Observed behavior**
the following line is present in `~/.cabal/config`:
```
-- ghc-options:
```

**System information**
- Operating system: Arch 6.2.13
- cabal: 3.4.1.0
- ghc: 9.0.2

**Additional context**
This might be relevant for the new-user experience on Arch Linux. https://wiki.archlinux.org/title/Haskell#Configuring_Cabal_for_dynamic_linking

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.