在OS X上安装Yesod时编译错误

时间:2014-01-17 17:35:23

标签: haskell cabal yesod

我对Haskell很新,并尝试使用Cabal安装Yesod,但我遇到了这个编译错误:

cabal install yesod --force-reinstalls


Network/Wai/Parse.hs:106:61:
    No instance for (Control.Monad.Trans.Resource.Internal.MonadThrow
                       (ConduitM S8.ByteString Void IO))
      arising from a use of `allocate'
    Possible fix:
      add an instance declaration for
      (Control.Monad.Trans.Resource.Internal.MonadThrow
         (ConduitM S8.ByteString Void IO))
    In the second argument of `($)', namely
      `allocate
         (do { tempDir <- getTmpDir;
               openBinaryTempFile tempDir pattern })
         (\ (_, h) -> hClose h)'
    In a stmt of a 'do' block:
      (key, (fp, h)) <- flip runInternalState internalState
                        $ allocate
                            (do { tempDir <- getTmpDir;
                                  openBinaryTempFile tempDir pattern })
                            (\ (_, h) -> hClose h)
    In the expression:
      do { (key, (fp, h)) <- flip runInternalState internalState
                             $ allocate
                                 (do { tempDir <- getTmpDir;
                                       openBinaryTempFile tempDir pattern })
                                 (\ (_, h) -> hClose h);
           _ <- runInternalState (register $ removeFile fp) internalState;
           CB.sinkHandle h;
           lift $ release key;
           .... }
Failed to install wai-extra-2.0.2

This is the full output when installing

我正在使用带有ghc-clang-wrapper脚本的最新Haskell平台。

Cabal版本:

$ cabal --version
cabal-install version 1.16.0.2
using version 1.16.0 of the Cabal library

GHC版本:

$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.6.3

有些教程提到使用cabal沙箱,但我的cabal版本(1.16)太旧了。如果沙盒可能太过帮助,我会尝试让它工作(将cabal更新到1.18时有点麻烦)。

1 个答案:

答案 0 :(得分:0)

看起来你有几个模块安装在现有模块旁边会导致名称冲突。在您发布错误之前的输出中,有一堆错误,如下所示:

Network/HTTP/Client/Conduit.hs:37:9:
   Ambiguous occurrence `MonadResource'
   It could refer to either `Data.Conduit.MonadResource',
    imported from `Data.Conduit' at Network/HTTP/Client/Conduit.hs:13:1-19
    (and originally defined in `resourcet-0.4.10:Control.Monad.Trans.Resource.Internal')
   or `Control.Monad.Trans.Resource.MonadResource',
    imported from `Control.Monad.Trans.Resource' at Network/HTTP/Client/Conduit.hs:15:1-35
    (and originally defined in `Control.Monad.Trans.Resource.Internal')

这些可能是由--force-reinstalls引起的。这基本上是为cabal sandbox创建的,因此可能更容易发布有关更新内容出错的问题。您应该能够cabal install cabal-install将其更新为最新版本。

编辑:

如果cabal install cabal-install正在发挥作用,那么我要检查的第一件事就是Chrules提到的,就是你指向的路径。当您通过cabal安装cabal时,它将被放入~/.cabal/bin,因此需要首先在您的路径中。如果您执行which cabal,我现在可能会看到/usr/bin/cabal之类的内容,您希望~/.cabal/bin/cabalrm -rf ~/.cabal ~/.ghc # This deletes everything you installed with cabal cabal update # Reinitialize the platform cabal cabal install cabal-install # Update cabal cabal install yesod # This will work since you nuked your ~/.cabal and ~/.ghc 。既然你现在的本地用户包已经搞砸了,我会做什么。

yesod-bin

执行此操作后,您将无需安装任何内容,但是您可能还需要yesod,因为它具有~/.cabal/bin二进制文件({{1}})。