commercialhaskell / stack

The Haskell Tool Stack
http://haskellstack.org
BSD 3-Clause "New" or "Revised" License
3.95k stars 842 forks source link

Windows: zlib-0.7 now needs MSYS install of zlib system library #6557

Closed andreasabel closed 2 months ago

andreasabel commented 2 months ago

When bumping to latest Stackage nightly, which has upgraded zlib to 0.7, it seems that on Windows I now need to install the zlib library into MSYS2.

Bumping Stackage nightly to 2024-04-20 upgrades zlib to 0.7, and this needs a pkgconf-supported installation of the zlib system library. From the changelog at https://hackage.haskell.org/package/zlib-0.7.0.0/changelog:

Make flag pkg-config automatic and on by default.

https://github.com/haskell/zlib/blob/16571cb9731de4be121c729b6b00544b013bd9a2/zlib.cabal#L66-L69

With Stack on Windows, this triggered a build error: https://github.com/agda/agda/actions/runs/8763153892/job/24051720397#step:10:2869

Error: Cabal-simple_9p6GVs8J_3.10.2.0_ghc-9.8.2.exe: The pkg-config package 'zlib' is required but it could not be found.

Installing thezlib library with stack exec -- pacman -S ...-zlib fixed the problem. b6e154c (#7229) https://github.com/agda/agda/actions/runs/8763585687/job/24052629583?pr=7229#step:6:122

installing mingw-w64-x86_64-zlib...

Can this be fixed by updating the MSYS2 installation shipped with Stack?

Or should this be fixed elsewhere? E.g. one could turn off the pkg-config flag for zlib in the Stackage snapshots. But this seems not very future-oriented, since the pkgconfig-depends mechanism was to make package descriptions more complete.

Downstream:

See also:

mpilgrem commented 2 months ago

@andreasabel, the Stack-supplied MSYS2 is, indeed, a 'plain vanilla'/'out of the box' version. If users need specific MSYS2 packages, as you identify, they can install them with pacman in the Stack environment. This is documented at https://docs.haskellstack.org/en/stable/developing_on_windows/#developing-on-windows.

I am reluctant to change that basic approach, but I can extend the online documentation to give zlib >=0.7 as a specific example.

Bodigrim commented 2 months ago

The problem is that Stack does not distinguish between manual and automatic flags and - for the sake of reproducibility - refuses to do any solving. The only solution I can think of is to bake constraints: zlib -pkg-config into Stackage snapshots. It's not cool, but not a regression in comparison to zlib-0.6 (where pkg-config was off by default).

Bodigrim commented 2 months ago

FWIW I second the suggestion for Stack to preinstall pkg-config into its MSYS environment. pkg-config is a more secure and sane way to do things and more packages will benefit from its existence in future.

mpilgrem commented 2 months ago

@Bodigrim, in that case (your seconding), I'll consult more widely. EDIT: In April 2022, I was of the same mind: https://github.com/commercialhaskell/stack/issues/1586#issuecomment-1107449752.

andreasabel commented 2 months ago

bake constraints: zlib -pkg-config into Stackage snapshots.

That would be: