Skip to content

Conversation

@phadej
Copy link
Collaborator

@phadej phadej commented Jul 8, 2025

No description provided.

@phadej phadej force-pushed the error-unused-packages branch from ed97f96 to ba20f0b Compare July 8, 2025 14:20
Also add -Werror=missing-fields when -Werror=missing-methods is used
@phadej phadej force-pushed the error-unused-packages branch from cd9d4ea to dca8934 Compare July 8, 2025 15:01
@phadej phadej marked this pull request as ready for review July 8, 2025 15:42
@phadej phadej merged commit eaa5a23 into master Jul 8, 2025
9 checks passed
@phadej phadej deleted the error-unused-packages branch July 8, 2025 15:42
@andreasabel
Copy link
Contributor

@phadej: Thanks for updating Haskell CI to GHC 9.14.

When refreshing my CIs for GHC 9.14 alpha1, I got hit by -Werror=unused-packages in many project, leading me to make patch releases on hackage:
Screenshot 2025-08-26 at 12 20 19
In case of http-io-streams, the new error was a bit problematic:

  1. Haskell CI first failed on this error.
  2. I ran cabal build --enable-tests --ghc-options=-Werror=unused-packages locally and removed the indicated dependencies.
  3. Haskell CI now failed on a missing dependency directory.
  4. Turned out that directory was needed on Linux (Haskell CI), but not on macOS (my local machine).

So, -Werror=unused-packages can give different results depending on the configuration (e.g. OS). However, Haskell CI tests only a single configuration (OS=Linux). Thus, the errors raised by Haskell CI might lead to the introduction of build errors.
In general, the new error is unsound (like an optimization that only works on a certain architecture but is enabled unconditionally in the compiler).

I suggest to not make this error default, but by default only warn about unused packages.

P.S.: My situation was still benign, since Haskell CI requires more dependencies than my local build. The other way round the situation could have been fatal, leading me to release a package that is broken on OSs other than Linux.

P.P.S: I also wonder whether removal of "unused packages" is not unsound in a second sense, because even though they are unused by the SUT they could be used by some dependency, so the constraints of the "unused" package might not be unused at all but determine versions of other dependencies.

@phadej
Copy link
Collaborator Author

phadej commented Aug 26, 2025

That's why I don't claim that haskell-ci is the only CI you'd ever need. If you have system-dependent code, you definitely should (at least smoke) test on different systems.

Default won't change. -Wunused-packages have been very helpful in my experience, and I'd be annoyed to enable it for every repository.

@phadej
Copy link
Collaborator Author

phadej commented Aug 26, 2025

but by default only warn about unused packages.

No-one looks at the warnings in CI run. I definitely don't.

@andreasabel
Copy link
Contributor

I guess putting error-unused-packages: False into cabal.haskell-ci will turn it off?

@phadej
Copy link
Collaborator Author

phadej commented Aug 26, 2025

Yes

@andreasabel
Copy link
Contributor

You might also be interested in this soundness bug for unused-packages:

Warning unused-packages does not take #if MIN_VERSION_pkg conditionals into account

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants