c2hs与Mac OS X 10.7.5的安装错误

时间:2013-12-15 22:46:06

标签: haskell cabal 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。

2 个答案:

答案 0 :(得分:1)

这个安装现在在我的Ubuntu盒子上工作,所以我可以肯定地说c2hs现在并没有被所有人打破。

我认为您可能有版本问题....尝试

cabal update

再次尝试安装。

特别是 -

最近将Prelude.catch函数移动到Control.Exception.catch,请参阅https://ghc.haskell.org/trac/ghc/ticket/4865。我下载了c2hs源代码(使用cabal unpack 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?只是尝试编译一个带有虚拟引用的空程序来捕获,就像这样 -

    导入Control.Exception

    x = catch

    main = undefined

  2. 您自动生成的Paths_c2hs.hs是否指向正确的catch函数。只需使用cabal解压缩,配置和构建c2hs,然后查看dist / build / autogen / Paths_c2hs.hs。 (您可能会在构建阶段遇到错误,但鉴于您在上面显示的内容,它将在创建Paths_c2hs.hs之后发生。)

答案 1 :(得分:0)

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

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

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

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

相关问题