Skip to content

Explicitly use Posix's splitDirectories #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

fendor
Copy link
Contributor

@fendor fendor commented Jul 10, 2022

Fixes build on windows.

See logs from HLS CI:

Build profile: -w ghc-8.10.7 -O1
In order, the following will be built (use -v for more details):
 - cabal-fmt-0.1.5.1 (lib:cabal-fmt-internal) (requires build)
 - ghc-check-0.5.0.6 (lib) (requires build)
 - ghc-exactprint-0.6.4 (lib) (requires build)
 - uuid-1.3.15 (lib) (requires build)
 - cabal-fmt-0.1.5.1 (exe:cabal-fmt) (requires build)
 - retrie-1.1.0.0 (lib) (requires build)
 - lsp-1.4.0.0 (lib) (requires build)
 - hls-plugin-api-1.4.0.0 (lib) (configuration changed)
 - ghcide-1.7.0.1 (lib) (configuration changed)
 - hls-test-utils-1.3.0.0 (lib) (configuration changed)
 - hls-cabal-fmt-plugin-0.1.0.0 (lib) (configuration changed)
 - hls-cabal-fmt-plugin-0.1.0.0 (test:tests) (first run)
Starting     ghc-check-0.5.0.6 (lib)
Starting     cabal-fmt-0.1.5.1 (lib:cabal-fmt-internal)
Building     ghc-check-0.5.0.6 (lib)
Building     cabal-fmt-0.1.5.1 (lib:cabal-fmt-internal)
Starting     ghc-exactprint-0.6.4 (lib)
Installing   ghc-check-0.5.0.6 (lib)
Completed    ghc-check-0.5.0.6 (lib)
Building     ghc-exactprint-0.6.4 (lib)
Installing   ghc-exactprint-0.6.4 (lib)
Completed    ghc-exactprint-0.6.4 (lib)
Failed to build lib:cabal-fmt-internal from cabal-fmt-0.1.5.1.
Build log (
C:\cabal\logs\ghc-8.10.7\cabal-fmt-0.1.5.1-edd3d86618a0e30a3d90a13e6d76b4ca89209696.log
):
Preprocessing library 'cabal-fmt-internal' for cabal-fmt-0.1.5.1..
Building library 'cabal-fmt-internal' for cabal-fmt-0.1.5.1..
[ 1 of 20] Compiling CabalFmt.Error   ( src\CabalFmt\Error.hs, dist\build\cabal-fmt-internal\CabalFmt\Error.o )
[ 2 of 20] Compiling CabalFmt.Options ( src\CabalFmt\Options.hs, dist\build\cabal-fmt-internal\CabalFmt\Options.o )
cabal.exe: Failed to build lib:cabal-fmt-internal from cabal-fmt-0.1.5.1
(which is required by test:tests from hls-cabal-fmt-plugin-0.1.0.0). See the
[ 3 of 20] Compiling CabalFmt.Monad   ( src\CabalFmt\Monad.hs, dist\build\cabal-fmt-internal\CabalFmt\Monad.o )
build log above for details.
[ 4 of 20] Compiling CabalFmt.Prelude ( src\CabalFmt\Prelude.hs, dist\build\cabal-fmt-internal\CabalFmt\Prelude.o )
[ 5 of 20] Compiling CabalFmt.Parser  ( src\CabalFmt\Parser.hs, dist\build\cabal-fmt-internal\CabalFmt\Parser.o )
[ 6 of 20] Compiling CabalFmt.Glob    ( src\CabalFmt\Glob.hs, dist\build\cabal-fmt-internal\CabalFmt\Glob.o )
src\CabalFmt\Glob.hs:30:31: error:
Error:     Ambiguous occurrence ‘splitDirectories’
    It could refer to
       either ‘System.FilePath.Posix.splitDirectories’,
              imported from ‘System.FilePath.Posix’ at src\CabalFmt\Glob.hs:5:31-46
           or ‘CabalFmt.Prelude.splitDirectories’,
              imported from ‘CabalFmt.Prelude’ at src\CabalFmt\Glob.hs:7:1-23
              (and originally defined in ‘System.FilePath.Windows’)
   |
30 | match (Glob g1 gs0) fp = go0 (splitDirectories fp) where
   |                               ^^^^^^^^^^^^^^^^
src\CabalFmt\Glob.hs:50:24: error:
Error:     Ambiguous occurrence ‘splitDirectories’
    It could refer to
       either ‘System.FilePath.Posix.splitDirectories’,
              imported from ‘System.FilePath.Posix’ at src\CabalFmt\Glob.hs:5:31-46
           or ‘CabalFmt.Prelude.splitDirectories’,
              imported from ‘CabalFmt.Prelude’ at src\CabalFmt\Glob.hs:7:1-23
              (and originally defined in ‘System.FilePath.Windows’)
   |
50 | parseGlob input = case splitDirectories input of
   |                        ^^^^^^^^^^^^^^^^
Build profile: -w ghc-8.10.7 -O1

@phadej
Copy link
Owner

phadej commented Jul 10, 2022

I don't understand. What is the point?

@fendor
Copy link
Contributor Author

fendor commented Jul 10, 2022

I don't understand. What is the point?

The point of this PR is to be able to install cabal-fmt (from Hackage) on windows.

The build fails because the function splitDirectories is ambiguous, since the Prelude imports splitDirectories from System.FilePath, and in Glob.hs, we import System.FilePath.Posix. These two imports clash on windows systems, since splitDirectories from System.FilePath.Windows /= System.FilePath.Posix.

In the even wider context and point, we are working on an HLS plugin that uses cabal-fmt for formatting cabal files, see haskell/haskell-language-server#2047 for more details.

@bradrn
Copy link

bradrn commented Jul 24, 2022

I am also running into this problem on Windows. In my case, Flora uses cabal-fmt, but the errors mentioned above prevent me from installing it.

@phadej
Copy link
Owner

phadej commented Jul 24, 2022

Merged as part of #49

It wasn't that simple: paths on unix/windows is tricky business (especially when they are all just Strings: compiler doesn't point out errors).

@phadej phadej closed this Jul 24, 2022
@bradrn
Copy link

bradrn commented Jul 25, 2022

Thanks @phadej!

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