c2hs installation error with Mac OS X 10.7.5

265 views Asked by At

I'm trying to install c2hs with cabal install c2hs. I created ~/.cabal/bin to install the binary beforehand.

With the command cabal install c2hs to get the errors.

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

What is wrong with the installation? The ghc version is 7.6.3.

2

There are 2 answers

0
prosseek On BEST ANSWER

The issue was that I installed two different versions of ghc on my mac: one from brew install ghc and the other from haskell platform.

I had to install the newest version of haskell platform, but before doing that I also needed to uninstall old version uninstall-hs only VERSION and brew unistall ghc.

After reinstalling the newest haskell platform, the compilation works fine.

Other method can be using brew brew install haskell-platform.

0
jamshidh On

The install worked for me right now, on my Ubuntu box, so I can say for sure that c2hs isn't broken for everyone right now.

I think you might have version issues.... Try

cabal update

and try the install again.

In particular-

The function Prelude.catch was moved to Control.Exception.catch recently, see https://ghc.haskell.org/trac/ghc/ticket/4865. I downloaded the c2hs sources (using cabal unpack c2hs), and looked at what headers Paths_c2hs.hs needs (this seems to be the file with the import problems). This is what the imports section contained-

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

(Paths_c2hs.hs is autogenerated, so I had to build it first).

Indeed, it was using Control.Exception. Because this is a module in base, you should have it, and probably just have out of date/mismatched packages. (In fact, my file's line numbers don't match your error message line numbers above- This is another indication we are using different versions, and I believe mine is up to date :) .)

Although I think that the "cabal update" will fix the problem, if not, try looking in these two places-

  1. Does Control.Exception.catch exist in your base modules? Just try to compile an empty program with an dummy reference to catch, like this-

    import Control.Exception

    x = catch

    main = undefined

  2. Does your autogenerated Paths_c2hs.hs point to the correct catch function. Just use cabal to unpack, configure and build c2hs and then look at dist/build/autogen/Paths_c2hs.hs. (you will probably hit your error in the build phase, but given what you have shown above, it will happen after the Paths_c2hs.hs creation).