2013-12-15 81 views
0

我正在嘗試安裝c2hs與cabal install c2hs。 我創建了~/.cabal/bin以預先安裝二進制文件。與Mac OS X的c2hs安裝錯誤10.7.5

用命令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。

回答

0

的問題是我安裝我的Mac上兩個不同版本的GHC:一個從brew install ghchaskell platform其他。

我不得不安裝最新版本的haskell平臺,但在此之前我還需要卸載舊版本uninstall-hs only VERSIONbrew unistall ghc

重新安裝最新的haskell平臺後,編譯工作正常。

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

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需要的頭文件(這似乎是導入問題的文件)。這是進口部分contained-

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 =捕捉

    主要=未定義

  2. 請問您自動生成Paths_c2hs.hs指向正確的catch函數。只需使用cabal解包,配置和構建c2h,然後查看dist/build/autogen/Paths_c2hs.hs。 (你可能會在構建階段遇到你的錯誤,但考慮到你上面顯示的內容,它會在創建Paths_c2hs.hs之後發生)。