Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
lancelet opened this issue Dec 24, 2021 · 1 comment
Open

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

lancelet opened this issue Dec 24, 2021 · 1 comment

Comments

@lancelet
Copy link

lancelet commented Dec 24, 2021

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
@Mikolaj
Copy link
Member

Mikolaj commented Jul 21, 2022

@lancelet: do any of the hints from #6112 help in your case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants