Search code examples
haskellcabalhaskell-platformhakyll

Haskell package build error


I created a cabal sandbox and I'm trying to build hakyll Haskell package on my OSX but i get build error on package temporary-1.2.0.2. What can be the reason?
cabal version is 1.20
Build error is below:

abcdef-MacBook-Pro:hakyll bd$ cabal install temporary
Resolving dependencies...
Configuring temporary-1.2.0.2...
Building temporary-1.2.0.2...
Preprocessing library temporary-1.2.0.2...
[1 of 3] Compiling Distribution.Compat.Exception ( Distribution/Compat/Exception.hs, dist/dist-sandbox-352cd149/build/Distribution/Compat/Exception.o )
[2 of 3] Compiling Distribution.Compat.TempFile ( Distribution/Compat/TempFile.hs, dist/dist-sandbox-352cd149/build/Distribution/Compat/TempFile.o )
[3 of 3] Compiling System.IO.Temp   ( System/IO/Temp.hs, dist/dist-sandbox-352cd149/build/System/IO/Temp.o )

System/IO/Temp.hs:59:3:
    Could not deduce (MonadMask m) arising from a use of `bracket'
    from the context (MonadIO m, MonadCatch m)
      bound by the type signature for
                 withTempFile :: (MonadIO m, MonadCatch m) =>
                                 FilePath -> String -> (FilePath -> Handle -> m a) -> m a
      at System/IO/Temp.hs:(53,17)-(57,19)
    Possible fix:
      add (MonadMask m) to the context of
        the type signature for
          withTempFile :: (MonadIO m, MonadCatch m) =>
                          FilePath -> String -> (FilePath -> Handle -> m a) -> m a
    In the expression:
      bracket
        (liftIO (openTempFile tmpDir template))
        (\ (name, handle)
           -> liftIO (hClose handle >> ignoringIOErrors (removeFile name)))
        (uncurry action)
    In an equation for `withTempFile':
        withTempFile tmpDir template action
          = bracket
              (liftIO (openTempFile tmpDir template))
              (\ (name, handle)
                 -> liftIO (hClose handle >> ignoringIOErrors (removeFile name)))
              (uncurry action)

System/IO/Temp.hs:79:3:
    Could not deduce (MonadMask m) arising from a use of `bracket'
    from the context (MonadCatch m, MonadIO m)
      bound by the type signature for
                 withTempDirectory :: (MonadCatch m, MonadIO m) =>
                                      FilePath -> String -> (FilePath -> m a) -> m a
      at System/IO/Temp.hs:(73,22)-(77,24)
    Possible fix:
      add (MonadMask m) to the context of
        the type signature for
          withTempDirectory :: (MonadCatch m, MonadIO m) =>
                               FilePath -> String -> (FilePath -> m a) -> m a
    In the expression:
      bracket
        (liftIO (createTempDirectory targetDir template))
        (liftIO . ignoringIOErrors . removeDirectoryRecursive)
    In an equation for `withTempDirectory':
        withTempDirectory targetDir template
          = bracket
              (liftIO (createTempDirectory targetDir template))
              (liftIO . ignoringIOErrors . removeDirectoryRecursive)
Failed to install temporary-1.2.0.2
cabal: Error: some packages failed to install:
temporary-1.2.0.2 failed during the building phase. The exception was:
ExitFailure 1

Solution

  • This is due to a bug in the 'temporary' package: https://github.com/batterseapower/temporary/pull/12

    Due to the maintainer not being responsive, there hasn't been an update to temporary on hackage, and someone has created a temporary-rc fork for the time being.

    From what I can tell the 'temporary' dependency is from pandoc and pandoc-citeproc. I was able to install hakyll by doing the following, which is rather hacky but worked for me and doesn't require downloading and modifying a bunch of packages to use 'temporary-rc' instead of 'temporary'.

    1. Download temporary-rc to a temp folder via cabal get temporary-rc
    2. Edit temporary-rc.cabal and change the "name:" field (first line) from 'temporary-rc' to 'temporary'
    3. I'm using sandboxes, so if you are, do cabal sandbox add-source <path/to/temporary-rc> (the temporary-rc folder in your temp directory from the last step)
      • If you're not using sandboxes, I imagine you can just do a cabal install from the temporary-rc folder to install it into your user package-db. I haven't tested this.
    4. Install hakyll normally and it should pick up the revised 'temporary' package.

    If you want to follow along at home, there's a thread on haskell-libraries discussing the situation.