cabal icon indicating copy to clipboard operation
cabal copied to clipboard

"cabal user-config update" doesn't work with nested config fields

Open TerrorJack opened this issue 5 years ago • 4 comments

Describe the bug Generate a standard cabal config file with cabal user-config init, then modify a field within another field (e.g. ar-location within program-locations). Calling cabal user-config diff would result in:

+ ar-location: /bin/my-custom-ar

But trying to apply the patch above with cabal user-config update -a "ar-location: /bin/my-custom-ar" would result in the following error:

cabal: Error parsing additional config lines: Unrecognized field ar-location
on line 1

The same error applies to all updates to nested config fields. It seems cabal user-config update only works when the diff provided by -a is only a top-level field.

To Reproduce See above.

System information

  • Operating system: Ubuntu 20.04 LTS
  • cabal-3.2.0.0

TerrorJack avatar May 19 '20 13:05 TerrorJack

I figured it out; one needs to pass -a program-locations\n ar-location: /bin/my-custom-ar to apply the diff. So the bug should be cabal user-config diff outputing a clearer diff which works for nested fields instead. Feel free to close this one.

TerrorJack avatar May 19 '20 13:05 TerrorJack

One could argue that program-locations\n ar-location: /bin/my-custom-ar is not really a good syntax. So let us keep this open until we figure out how to better.

phadej avatar May 19 '20 13:05 phadej

cabal user-config update does not work with program-default-options at all:

$ cabal user-config update -a '
program-default-options
  ghc-pkg-options: --foo
'

This leaves the ~/.cabal/config unchanged.

It might be related to https://github.com/haskell/cabal/issues/6823.

Rufflewind avatar May 31 '21 23:05 Rufflewind

Oh, the quotes are nice syntax. Reproduced. PRs welcome.

Mikolaj avatar Jun 02 '21 21:06 Mikolaj