Skip to content
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

Doesn't build with Cabal HEAD (2.1) #23

Closed
tfausak opened this issue Sep 29, 2017 · 2 comments
Closed

Doesn't build with Cabal HEAD (2.1) #23

tfausak opened this issue Sep 29, 2017 · 2 comments

Comments

@tfausak
Copy link

tfausak commented Sep 29, 2017

I am working on a project that requires features from the latest HEAD version of Cabal (see haskell/cabal#4799). Something in my dependency tree pulled in cabal-doctest which caused my build to fail with this error:

Error: While constructing the build plan, the following exceptions were encountered:

In the dependencies for cabal-doctest-1.0.2:
    Cabal-2.1.0.0 must match >=1.10 && <2.1 (latest applicable is 2.0.0.2)
needed due to example-0.0.0 -> cabal-doctest-1.0.2

Plan construction failed.

I initially thought this was a problem with distributive (see ekmett/distributive#37) but was sent here instead.

I tried to fix this by bumping the bounds (--allow-newer), but the build failed:

    /private/tmp/cabal-doctest/src/Distribution/Extra/Doctest.hs:227:7: error:
        • Couldn't match expected type ‘IO ()’
                      with actual type ‘String -> IO ()’
        • In a stmt of a 'do' block:
            rewriteFile (testAutogenDir </> "Build_doctests.hs")
            $ unlines
                ["module Build_doctests where", "", "import Prelude", "", ....]
          In the second argument of ‘($)’, namely
            ‘do { let testBI = testBuildInfo suite;
                  let additionalFlags
                        = maybe ... words
                          $ lookup "x-doctest-options" $ customFieldsBI testBI;
                  let additionalModules
                        = maybe ... words
                          $ lookup "x-doctest-modules" $ customFieldsBI testBI;
                  let additionalDirs'
                        = maybe ... words
                          $ lookup "x-doctest-source-dirs" $ customFieldsBI testBI;
                  .... }’
          In the expression:
            when (testName suite == fromString testSuiteName)
            $ do { let testBI = testBuildInfo suite;
                   let additionalFlags
                         = maybe ... words
                           $ lookup "x-doctest-options" $ customFieldsBI testBI;
                   let additionalModules
                         = maybe ... words
                           $ lookup "x-doctest-modules" $ customFieldsBI testBI;
                   let additionalDirs'
                         = maybe ... words
                           $ lookup "x-doctest-source-dirs" $ customFieldsBI testBI;
                   .... }
    
    /private/tmp/cabal-doctest/src/Distribution/Extra/Doctest.hs:227:20: error:
        • Couldn't match type ‘[Char]’
                         with ‘Distribution.Verbosity.Verbosity’
          Expected type: Distribution.Verbosity.Verbosity
            Actual type: FilePath
        • In the first argument of ‘rewriteFile’, namely
            ‘(testAutogenDir </> "Build_doctests.hs")’
          In the expression:
            rewriteFile (testAutogenDir </> "Build_doctests.hs")
          In a stmt of a 'do' block:
            rewriteFile (testAutogenDir </> "Build_doctests.hs")
            $ unlines
                ["module Build_doctests where", "", "import Prelude", "", ....]
@RyanGlScott
Copy link
Collaborator

It looks like the type of rewriteFile changed in Cabal HEAD: haskell/cabal@0aa73b7#diff-fe949fe985d4f115d0eee5b8268ef014R1385

Perhaps this patch would do the trick? (Disclaimer: I haven't tried compiling this.)

diff --git a/src/Distribution/Extra/Doctest.hs b/src/Distribution/Extra/Doctest.hs
index b87b811..239eb70 100644
--- a/src/Distribution/Extra/Doctest.hs
+++ b/src/Distribution/Extra/Doctest.hs
@@ -224,7 +224,12 @@ generateBuildModule testSuiteName flags pkg lbi = do
       createDirectoryIfMissingVerbose verbosity True testAutogenDir
 
       -- write autogen'd file
-      rewriteFile (testAutogenDir </> "Build_doctests.hs") $ unlines
+#if MIN_VERSION_Cabal(2,1,0)
+      rewriteFile verbosity
+#else
+      rewriteFile
+#endif
+                  (testAutogenDir </> "Build_doctests.hs") $ unlines
         [ "module Build_doctests where"
         , ""
         , "import Prelude"

@RyanGlScott
Copy link
Collaborator

Actually, this change to rewriteFile's type signature was reverted in haskell/cabal@5797013, so as of GHC 8.4.1-alpha2 (which comes shipped with Cabal-2.1.0.0), cabal-doctest-1.0.4 builds without any changes! In light of this, I'll close this issue.

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

No branches or pull requests

2 participants