Gabriella439 / turtle

Shell programming, Haskell style
BSD 3-Clause "New" or "Revised" License
943 stars 90 forks source link

Error while compiling on Windows #422

Closed bingis-khan closed 2 years ago

bingis-khan commented 2 years ago

The error is during compilation of Turtle on GHC 9.0.2 on Windows. Couldn't find any info about this issue, so I'm posting it here.

The following is the console output after executing stack build:

WARNING: Ignoring turtle's bounds on Win32 (>=2.2.0.1 && <2.9); using Win32-2.12.0.1.
Reason: trusting snapshot over cabal file dependency information.
turtle> configure
turtle> Configuring turtle-1.5.24...
turtle> build
turtle> Preprocessing library for turtle-1.5.24..
turtle> Building library for turtle-1.5.24..
turtle> [ 1 of 10] Compiling Turtle.Internal
turtle> [ 2 of 10] Compiling Turtle.Line
turtle> [ 3 of 10] Compiling Turtle.Format
turtle> 
turtle> src\Turtle\Format.hs:72:1: warning: [-Wunused-imports]
turtle>     The import of ‘Data.Monoid’ is redundant
turtle>       except perhaps to import instances from ‘Data.Monoid’
turtle>     To import instances alone, use: import Data.Monoid()
turtle>    |
turtle> 72 | import Data.Monoid ((<>))
turtle>    | ^^^^^^^^^^^^^^^^^^^^^^^^^
turtle> [ 4 of 10] Compiling Turtle.Options
turtle> [ 5 of 10] Compiling Turtle.Pattern
turtle> [ 6 of 10] Compiling Turtle.Shell
turtle> 
turtle> src\Turtle\Shell.hs:89:1: warning: [-Wunused-imports]
turtle>     The import of ‘Data.Foldable’ is redundant
turtle>       except perhaps to import instances from ‘Data.Foldable’
turtle>     To import instances alone, use: import Data.Foldable()
turtle>    |
turtle> 89 | import Data.Foldable (Foldable)
turtle>    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
turtle> [ 7 of 10] Compiling Turtle.Prelude
turtle> 
turtle> src\Turtle\Prelude.hs:1240:38: error:
turtle>     • Couldn't match expected type ‘Maybe Win32.FILETIME’
turtle>                   with actual type ‘Win32.FILETIME’
turtle>     • In the second argument of ‘Win32.setFileTime’, namely
turtle>         ‘creationTime’
turtle>       In a stmt of a 'do' block:
turtle>         Win32.setFileTime handle creationTime systemTime systemTime
turtle>       In the expression:
turtle>         do handle <- Win32.createFile
turtle>                        (Filesystem.encodeString file) Win32.gENERIC_WRITE
turtle>                        Win32.fILE_SHARE_NONE Nothing Win32.oPEN_EXISTING
turtle>                        Win32.fILE_ATTRIBUTE_NORMAL Nothing
turtle>            (creationTime, _, _) <- Win32.getFileTime handle
turtle>            systemTime <- Win32.getSystemTimeAsFileTime
turtle>            Win32.setFileTime handle creationTime systemTime systemTime
turtle>      |
turtle> 1240 |             Win32.setFileTime handle creationTime systemTime systemTime
turtle>      |                                      ^^^^^^^^^^^^
turtle>
turtle> src\Turtle\Prelude.hs:1240:51: error:
turtle>     • Couldn't match expected type ‘Maybe Win32.FILETIME’
turtle>                   with actual type ‘Win32.FILETIME’
turtle>     • In the third argument of ‘Win32.setFileTime’, namely ‘systemTime’
turtle>       In a stmt of a 'do' block:
turtle>         Win32.setFileTime handle creationTime systemTime systemTime
turtle>       In the expression:
turtle>         do handle <- Win32.createFile
turtle>                        (Filesystem.encodeString file) Win32.gENERIC_WRITE
turtle>                        Win32.fILE_SHARE_NONE Nothing Win32.oPEN_EXISTING
turtle>                        Win32.fILE_ATTRIBUTE_NORMAL Nothing
turtle>            (creationTime, _, _) <- Win32.getFileTime handle
turtle>            systemTime <- Win32.getSystemTimeAsFileTime
turtle>            Win32.setFileTime handle creationTime systemTime systemTime
turtle>      |
turtle> 1240 |             Win32.setFileTime handle creationTime systemTime systemTime
turtle>      |                                                   ^^^^^^^^^^
turtle>
turtle> src\Turtle\Prelude.hs:1240:62: error:
turtle>     • Couldn't match expected type ‘Maybe Win32.FILETIME’
turtle>                   with actual type ‘Win32.FILETIME’
turtle>     • In the fourth argument of ‘Win32.setFileTime’, namely
turtle>         ‘systemTime’
turtle>       In a stmt of a 'do' block:
turtle>         Win32.setFileTime handle creationTime systemTime systemTime
turtle>       In the expression:
turtle>         do handle <- Win32.createFile
turtle>                        (Filesystem.encodeString file) Win32.gENERIC_WRITE
turtle>                        Win32.fILE_SHARE_NONE Nothing Win32.oPEN_EXISTING
turtle>                        Win32.fILE_ATTRIBUTE_NORMAL Nothing
turtle>            (creationTime, _, _) <- Win32.getFileTime handle
turtle>            systemTime <- Win32.getSystemTimeAsFileTime
turtle>            Win32.setFileTime handle creationTime systemTime systemTime
turtle>      |
turtle> 1240 |             Win32.setFileTime handle creationTime systemTime systemTime
turtle>      |                                                              ^^^^^^^^^^
Progress 1/2

--  While building package turtle-1.5.24 (scroll up to its section to see the error) using:
      C:\Users\bingis_khan\AppData\Roaming\stack\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_3.4.1.0_ghc-9.0.2.exe --builddir=.stack-work\dist\d53b6a14 build --ghc-options " -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1

GHC 9.0.2. New Stack project.

bingis-khan commented 2 years ago

Ok, I know it's because Stack ignores version bounds - is it possible for Stack to respect Cabal's version of choice?

Gabriella439 commented 2 years ago

I don't know. You'd have to ask the stack maintainers

bingis-khan commented 2 years ago

Ok, I did the monke brain thing and just changed the call to (Just x) from just x with the new Win32 version:

I mention the last two, because I've never published a package, so I don't know if it's safe. I'm asking before a pull request to make sure I haven't goofed up.

Gabriella439 commented 2 years ago

Yeah, that sounds like a safe change to make

bingis-khan commented 2 years ago

If someone wants to use this version, see: https://docs.haskellstack.org/en/stable/yaml_configuration/#extra-deps

Generally when are repository changes uploaded to hackage/stackage?

Gabriella439 commented 2 years ago

I will upload this soon. I typically upload changes when at least 1 month has passed since the last release

Gabriella439 commented 2 years ago

This is on Hackage now as turtle-1.5.25