Gabriella439 / turtle

Shell programming, Haskell style

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`turtle-1.6.0` fails to compile on Windows

RyanGlScott opened this issue · comments

Building turtle-1.6.0 on Windows with GHC 9.2.3 fails with:

[ 7 of 10] Compiling Turtle.Prelude   ( src\Turtle\Prelude.hs, dist\build\Turtle\Prelude.o )

src\Turtle\Prelude.hs:985:35: error:
    Not in scope: ‘Filesystem.encodeString’
    No module named ‘Filesystem’ is imported.
    |
985 |             (Win32.findFirstFile (Filesystem.encodeString (path </> "*")))
    |                                   ^^^^^^^^^^^^^^^^^^^^^^^

src\Turtle\Prelude.hs:990:36: error:
    Not in scope: ‘Filesystem.decodeString’
    No module named ‘Filesystem’ is imported.
    |
990 |                         let file = Filesystem.decodeString file'
    |                                    ^^^^^^^^^^^^^^^^^^^^^^^

src\Turtle\Prelude.hs:1224:18: error:
    Not in scope: ‘Filesystem.encodeString’
    No module named ‘Filesystem’ is imported.
     |
1224 |                 (Filesystem.encodeString file)
     |                  ^^^^^^^^^^^^^^^^^^^^^^^

This patch is sufficient to make Turtle.Prelude compile:

diff --git a/src/Turtle/Prelude.hs b/src/Turtle/Prelude.hs
index d1edc52..4595c6b 100644
--- a/src/Turtle/Prelude.hs
+++ b/src/Turtle/Prelude.hs
@@ -982,13 +982,12 @@ ls path = Shell (\(FoldShell step begin done) -> do
     reparse <- fmap reparsePoint (Win32.getFileAttributes path')
     if (canRead && not reparse)
         then bracket
-            (Win32.findFirstFile (Filesystem.encodeString (path </> "*")))
+            (Win32.findFirstFile (path </> "*"))
             (\(h, _) -> Win32.findClose h)
             (\(h, fdat) -> do
                 let loop x = do
-                        file' <- Win32.getFindDataFileName fdat
-                        let file = Filesystem.decodeString file'
-                        x' <- if (file' /= "." && file' /= "..")
+                        file <- Win32.getFindDataFileName fdat
+                        x' <- if (file /= "." && file /= "..")
                             then step x (path </> file)
                             else return x
                         more <- Win32.findNextFile h fdat
@@ -1221,7 +1220,7 @@ touch file = do
 #ifdef mingw32_HOST_OS
         then do
             handle <- Win32.createFile
-                (Filesystem.encodeString file)
+                file
                 Win32.gENERIC_WRITE
                 Win32.fILE_SHARE_NONE
                 Nothing

However, the cptree and system-filepath-tests test suites fail after making this change:

$ cabal test test:cptree -w ghc-9.2.3
Build profile: -w ghc-9.2.3 -O1
In order, the following will be built (use -v for more details):
 - turtle-1.6.0 (test:cptree) (first run)
Preprocessing test suite 'cptree' for turtle-1.6.0..
Building test suite 'cptree' for turtle-1.6.0..
Running 1 test suites...
Test suite cptree: RUNNING...
cptree.exe: user error (cptree did not preserve directory)

Test suite cptree: FAIL
Test suite logged to:
C:\Users\winferno\Documents\Hacking\Haskell\sandbox\turtle\dist-newstyle\build\x86_64-windows\ghc-9.2.3\turtle-1.6.0\t\cptree\test\turtle-1.6.0-cptree.log
0 of 1 test suites (0 of 1 test cases) passed.
cabal-3.6.2.0.exe: Tests failed for test:cptree from turtle-1.6.0.
$ cabal test test:system-filepath-tests -w ghc-9.2.3
Build profile: -w ghc-9.2.3 -O1
In order, the following will be built (use -v for more details):
 - turtle-1.6.0 (test:system-filepath-tests) (first run)
Preprocessing test suite 'system-filepath-tests' for turtle-1.6.0..
Building test suite 'system-filepath-tests' for turtle-1.6.0..
Running 1 test suites...
Test suite system-filepath-tests: RUNNING...
system-filepath tests
  root:             FAIL
    test\system-filepath.hs:30:
    expected: "/"
     but got: ""
    Use -p '/root/' to rerun this test only.
  directory:        OK
  parent:           FAIL
    test\system-filepath.hs:62:
    expected: "/"
     but got: "./"
    Use -p '/parent/' to rerun this test only.
  commonPrefix:     OK
  stripPrefix:      OK
  collapse:         FAIL
    test\system-filepath.hs:179:
    expected: "foo/../bar"
     but got: "foo\\..\\bar"
    Use -p '/collapse/' to rerun this test only.
  filename:         OK
  dirname:          OK
  basename:         OK
  absolute:         OK
  relative:         FAIL
    test\system-filepath.hs:134:
    not $ relative "\\foo\\bar"
    Use -p '/relative/' to rerun this test only.
  splitDirectories: OK
  splitExtension:   OK

4 out of 13 tests failed (0.00s)

Test suite system-filepath-tests: FAIL
Test suite logged to:
C:\Users\winferno\Documents\Hacking\Haskell\sandbox\turtle\dist-newstyle\build\x86_64-windows\ghc-9.2.3\turtle-1.6.0\t\system-filepath-tests\test\turtle-1.6.0-system-filepath-tests.log
0 of 1 test suites (0 of 1 test cases) passed.
cabal-3.6.2.0.exe: Tests failed for test:system-filepath-tests from
turtle-1.6.0.

You're welcome! 🙂