【问题标题】:Compile error in Wai installing Yesod on OS X在 OS X 上安装 Yesod 时出现编译错误
【发布时间】:2014-02-07 03:49:35
【问题描述】:

我对 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 --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 有点麻烦)。

【问题讨论】:

    标签: haskell cabal yesod


    【解决方案1】:

    看起来您有几个模块,当安装在现有模块旁边时会导致名称冲突。在您发布错误之前的输出中进一步向上,有一堆这样的错误:

    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/cabal。由于您是本地用户包现在搞砸了,这就是我要做的。

    rm -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 之外,您将没有安装任何东西,并且您可能还需要 yesod-bin,因为它具有 yesod 二进制文件(~/.cabal/bin)。

    【讨论】:

    • 谢谢安德鲁。更新cabal 会显示成功消息(“Installed cabal-install-1.18.0.2”),但which cabal/cabal --version 仍会找到旧版本。这听起来很容易解决,所以我今晚会解决这个问题并尝试cabal sandbox
    • 您希望 ~/.cabal/bin 在您的路径中排在第一位。你可能是从 /usr/bin 或类似的地方点击你的发行版的 yesod,所以当它更新时,仍然首先选择旧版本。
    猜你喜欢
    • 2012-08-28
    • 1970-01-01
    • 1970-01-01
    • 2015-07-08
    • 1970-01-01
    • 1970-01-01
    • 2013-05-05
    • 2016-07-22
    • 1970-01-01
    相关资源
    最近更新 更多