Mac OS X 10.7.5的c2hs安装错误



我正在尝试用cabal install c2hs安装c2hs。我创建了~/.cabal/bin来预先安装二进制文件。

使用命令cabal install c2hs获取错误。

src/Control/StateTrans.hs:77:1: Warning:
    Module `Prelude' does not export `catch'
[ 3 of 26] Compiling Data.Errors      ( src/Data/Errors.hs, dist/build/c2hs/c2hs-tmp/Data/Errors.o )
[ 4 of 26] Compiling Data.Attributes  ( src/Data/Attributes.hs, dist/build/c2hs/c2hs-tmp/Data/Attributes.o )
[ 5 of 26] Compiling Text.Lexers      ( src/Text/Lexers.hs, dist/build/c2hs/c2hs-tmp/Text/Lexers.o )
[ 6 of 26] Compiling Control.StateBase ( src/Control/StateBase.hs, dist/build/c2hs/c2hs-tmp/Control/StateBase.o )
[ 7 of 26] Compiling Data.NameSpaces  ( src/Data/NameSpaces.hs, dist/build/c2hs/c2hs-tmp/Data/NameSpaces.o )
[ 8 of 26] Compiling C2HS.C.Attrs     ( src/C2HS/C/Attrs.hs, dist/build/c2hs/c2hs-tmp/C2HS/C/Attrs.o )
[ 9 of 26] Compiling C2HS.C.Builtin   ( src/C2HS/C/Builtin.hs, dist/build/c2hs/c2hs-tmp/C2HS/C/Builtin.o )
[10 of 26] Compiling Paths_c2hs       ( dist/build/autogen/Paths_c2hs.hs, dist/build/c2hs/c2hs-tmp/Paths_c2hs.o )
dist/build/autogen/Paths_c2hs.hs:21:13: Not in scope: `catch'
dist/build/autogen/Paths_c2hs.hs:22:13: Not in scope: `catch'
dist/build/autogen/Paths_c2hs.hs:23:14: Not in scope: `catch'
dist/build/autogen/Paths_c2hs.hs:24:17: Not in scope: `catch'
cabal: Error: some packages failed to install:
c2hs-0.16.5 failed during the building phase. The exception was:
ExitFailure 1

安装有什么问题?ghc版本为7.6.3。

安装现在在我的Ubuntu盒子上对我有效,所以我可以肯定地说,c2hs现在对每个人来说都没有坏。

我想你可能有版本问题。。。。尝试

cabal update

然后重试安装。

特别是

函数Prelude.catch最近被移到Control.Exception.catch,请参阅https://ghc.haskell.org/trac/ghc/ticket/4865.我下载了c2hs源代码(使用cabal解压c2hs),并查看了Paths_c2hs.hs需要的头文件(这似乎是存在导入问题的文件)。这就是进口部分包含的内容-

import qualified Control.Exception as Exception
import Data.Version (Version(..))
import System.Environment (getEnv)
import Prelude

(Paths_c2hs.hs是自动生成的,所以我必须先构建它)。

事实上,它使用的是Control.Exception。因为这是一个基础模块,所以你应该拥有它,而且可能只是有过时/不匹配的包。(事实上,我的文件行号与您上面的错误消息行号不匹配-这是我们使用不同版本的另一个迹象,我相信我的是最新的:)

虽然我认为"阴谋集团更新"会解决问题,如果不是,试着看看这两个地方-

  1. 基本模块中是否存在Control.Exception.catch?只需尝试编译一个带有伪引用的空程序来捕获,就像这样-

    导入控制。异常

    x=捕获

    main=未定义

  2. 您自动生成的Paths_c2hs.hs是否指向正确的catch函数。只需使用cabal解压缩、配置和构建c2hs,然后查看dist/build/autogen/Paths_c2hs.hs。

问题是我在mac上安装了两个不同版本的ghc:一个来自brew install ghc,另一个来自haskell平台。

我必须安装最新版本的haskell平台,但在此之前,我还需要卸载旧版本的uninstall-hs only VERSIONbrew unistall ghc

重新安装最新的haskell平台后,编译工作正常。

  • https://github.com/haskell/cabal/issues/1137
  • 如何在Mac OSX上安装适用于Haskell 7.6.1的Haskell cabal工具

其他方法可以使用酿造brew install haskell-platform

最新更新