RyanGlScott / mintty

A reliable way to detect the presence of a MinTTY console on Windows
BSD 3-Clause "New" or "Revised" License
4 stars 1 forks source link

`stack` incorrectly sets automatic flag `Win32-2-13-1` even when using `Win32-2.10` #4

Closed andreasabel closed 2 years ago

andreasabel commented 2 years ago

With stack resolver: nightly-2021-11-12 I encountered the following problem (stack 2.7.3 on Windows 10):

$ stack build --stack-yaml=stack-9.0.1.yaml --test
WARNING: Ignoring mintty's bounds on Win32 (>=2.13.1); using Win32-2.10.0.0.
Reason: trusting snapshot over cabal file dependency information.
mintty              > configure
mintty              > Configuring mintty-0.1.3...
mintty              > build
mintty              > Preprocessing library for mintty-0.1.3..
mintty              > Building library for mintty-0.1.3..
mintty              > [1 of 1] Compiling System.Console.MinTTY
mintty              >
mintty              > src\System\Console\MinTTY.hs:31:1: error:
mintty              >     Could not find module `System.Console.MinTTY.Win32'
mintty              >     Use -v (or `:set -v` in ghci) to see a list of the files searched for.
mintty              >    |
mintty              > 31 | import qualified System.Console.MinTTY.Win32 as Win32 (isMinTTY, isMinTTYHandle)
mintty              >    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Progress 1/11

--  While building package mintty-0.1.3 (scroll up to its section to see the error) using:
      C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_3.4.0.0_ghc-9.0.1.exe --builddir=.stack-work\dist\688fb2ce build --ghc-options " -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1

Is this maybe the same problem with stack not handling automatic flags correctly as experienced in https://github.com/haskell-hvr/regex-posix/issues/7#issuecomment-783131496 ?

flag Win32-2-13-1
  description:         Use @Win32-2.13.1.0@ or later. Older versions of @Win32@
                       either do not have functionality for detecting MinTTY or
                       have bugs in their MinTTY detection. For these versions
                       of @Win32@, we backport a working version of MinTTY
                       detection.
  default:             True
...
    if flag(Win32-2-13-1)
      build-depends:   Win32 >= 2.13.1
    else
      build-depends:   filepath
                     , Win32 < 2.13.1
      build-tools:     hsc2hs
      include-dirs:    include
      includes:        windows_cconv.h, winternl_compat.h
      other-modules:   System.Console.MinTTY.Win32

stack does not turn Win32-2-13-1 off automatically if Win32 is fixed to 2.10.*, rather it simply ignores the bound >= 2.13.1. This leads then to a build failure.

  1. Is there maybe a solution not involving an automatic flag?
  2. For the present solution, the resolver nightly-2021-11-12 should definitely include the setting
    flags:
     mintty:
       Win32-2-13-1: false

    The latter is actually a workaround; adding this to the .yaml file lets mintty compilation succeed.

andreasabel commented 2 years ago

So nightly got the setting exactly wrong:

RyanGlScott commented 2 years ago

Yeah, I'm inclined to believe that this is an issue with build-constraints.yaml in the upstream stackage repo. It's unclear to me why stack requires hard-coding the values of cabal flags in this way, but given stack's current combination of mintty and Win32 libraries, Win32-2-13-1 should definitely be false.

Should I file a PR against stackage, or would you be willing to do so?

andreasabel commented 2 years ago

I'll do; already at it!