Skip to content

Setup.hs: Clean hooks are no longer called. #7877

@lancelet

Description

@lancelet

Describe the bug
When using a custom Setup.hs file, the following hooks are not called when cabal clean is run:

  • preClean
  • cleanHook
  • postClean

(Addendum: AFAICT, Setup.hs is not called at all when cabal v2-clean is called.)

To Reproduce
Steps to reproduce the behavior:

$ mkdir temp
$ cd temp
$ cabal --version
cabal-install version 3.6.2.0
compiled using version 3.6.2.0 of the Cabal library
$ cabal init
...
$ cat temp.cabal  # edit temp.cabal so it looks like this:
cabal-version:      3.6
name:               temp
version:            0.1.0.0
extra-source-files: CHANGELOG.md

build-type: Custom
custom-setup
  setup-depends:
      base  ^>= 4.14
    , Cabal ^>= 3.6

executable temp
    main-is:          Main.hs
    build-depends:    base ^>=4.14.3.0
    hs-source-dirs:   app
    default-language: Haskell2010
$ cat Setup.hs  # edit Setup.hs so it looks like this:
module Main (main) where

import Distribution.Simple

main :: IO ()
main = do
  putStrLn "Confirm I'm using Setup.hs"
  defaultMainWithHooks $ simpleUserHooks
    { preClean  = \_ _     -> error "preClean should fail"
    , cleanHook = \_ _ _ _ -> error "clean should fail"
    , postClean = \_ _ _ _ -> error "postClean should fail"
    }
$ cabal v2-build
... # builds correctly; echoes "Confirm I'm using Setup.hs"
$ cabal v2-clean -v
Deleting dist-newstyle (/Users/jsm/workspace/temp/dist-newstyle)

Expected behavior
The three hook functions should be called. In the example above, that should throw an exception (but obviously the calls to error are just to illustrate that the hooks are not being called).

System information

  • macOS Monterey (v 12.1)
  • cabal version 3.6.2.0
  • ghc version 8.10.7

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions