Skip to content

Unrecognized Cabal flag error is printed to stdout #12178

Description

@fendor

Describe the bug

When a flag to a Setup.hs is not recognized, then the error message is printed to stdout.

This is not what I would have expected.

To Reproduce

$ mkdir a-with-custom
$ cd a-with-custom
$ cabal init --lib --minimal -n

Then modify the cabal file:

cabal-version:      3.0
name:               a-with-custom
version:            0.1.0.0
build-type:         Custom

custom-setup
    setup-depends:
        Cabal <3.16,
        base

library
    exposed-modules:  MyLib
    build-depends:    base
    hs-source-dirs:   src
    default-language: Haskell2010

Then run cabal repl src/MyLib.hs --keep-temp-files:

Warning: this is a debug build of cabal-install with assertions enabled.
Resolving dependencies...
Build profile: -w ghc-9.10.3 -O1
In order, the following will be built (use -v for more details):
 - a-with-custom-0.1.0.0 (interactive) (first run)
unrecognized 'repl' option `--keep-temp-files'
Error: [Cabal-7125]
repl failed for a-with-custom-0.1.0.0.

HasCallStack backtrace:
  collectBacktraces, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:169:13 in ghc-internal:GHC.Internal.Exception
  toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/IO.hs:260:11 in ghc-internal:GHC.Internal.IO
  throwIO, called at libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs:195:43 in ghc-internal:GHC.Internal.Control.Exception.Base

The error unrecognized 'repl' option `--keep-temp-files' is printed to stdout.

Expected behavior

The error message unrecognized 'repl' option --keep-temp-files'` should be printed to stderr, imo.

System information

  • Operating system
  • cabal3.16.1.0 and cabal HEAD 4907eec

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions