haskell / haskell/cabal

Setup.hs: Clean hooks are no longer called.

Open
#7,877 1 comment 0 reactions 0 assignees View on GitHub
cabal-install: cmd/clean Cabal: custom Cabal: hooks type: bug type: regression
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

**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

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.