z0w0/helm

Error on cabal install on Yosemite

shoooe opened this issue · 4 comments

I'm getting:

[10 of 11] Compiling FRP.Helm ( src/FRP/Helm.hs, dist/dist-sandbox-473dfa24/build/FRP/Helm.o )

src/FRP/Helm.hs:222:108:
Couldn't match type ‘[Char]’
with ‘text-1.1.0.0:Data.Text.Internal.Text’
Expected type: glib-0.13.0.5:System.Glib.UTFString.DefaultGlibString
Actual type: String
In the ‘Pango.paFamily’ field of a record
In the expression:
Pango.AttrFamily
{Pango.paStart = i, Pango.paEnd = j, Pango.paFamily = textTypeface}
cabal: Error: some packages failed to install:
helm-0.6.0 failed during the building phase. The exception was:
ExitFailure 1

trying to do cabal install helm inside a cabal sandbox using GHC 7.8.3.

This is very weird. The line in question is:

surface <- liftIO $ Cairo.imageSurfaceCreateFromPNG src

Now, Cairo's function imageSurfaceCreateFromPNG takes a FilePath as argument.

Now we know that src is a FilePath due to the fact that it's the first argument of:

getSurface :: FilePath -> Helm (Cairo.Surface, Int, Int)
getSurface src = do
    ...

Now Cairo's function also returns an IO Surface, which makes surface of type Cairo.Surface, that is correctly returned as first of a triple in Helm (Cairo.Surface, Int, Int).

So I really can't spot anything wrong with that line.

Woops. I seem to be looking at the wrong line, since the error actually refers to this line. Maybe I should try 0.7 instead of 0.6 from Hackage.

Now I'm getting:

 [2 of 2] Compiling Main             ( SetupMain.hs, dist/setup-wrapper/Main.o )
Linking dist/setup-wrapper/setup ...
Configuring glib-0.12.5.4...
Building glib-0.12.5.4...
Preprocessing library glib-0.12.5.4...
gtk2hsC2hs: Error in C header file.

 /usr/include/dirent.h:150: (column 10) [FATAL] 
  >>> Syntax error!
  The symbol `^' does not fit here.

I've installed GCC with 4.9 and then used:

PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig cabal install glib-0.12.5.4 --with-gcc=gcc-4.9
PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig cabal install pango-0.12.5.3 --with-gcc=gcc-4.9

to install glib and pango manually (that were both giving the above error), before calling cabal install helm-0.7.0.

You can probably just call cabal install helm-0.7.0 --with-gcc=gcc-4.9.

Ok, so if you are on Yosemite, you want to (additionally to the dependencies explained in the guide) run:

brew install gcc

This will install GCC 4.9 that was removed by Xcode's command line tools.

Then you can run:

caban sandbox init
cabal install gtk2hs-buildtools
cabal install helm --with-gcc=gcc-4.9

This will compile correctly every dependency. Now what I'm getting, though is this:

[13 of 13] Compiling FRP.Helm         ( src/FRP/Helm.hs, dist/dist-sandbox-473dfa24/build/FRP/Helm.o )

src/FRP/Helm.hs:91:31: Not in scope: ‘SDL.windowFlagShown’

src/FRP/Helm.hs:92:31: Not in scope: ‘SDL.windowFlagResizable’

src/FRP/Helm.hs:93:31: Not in scope: ‘SDL.windowFlagFullscreen’

src/FRP/Helm.hs:94:20: Not in scope: ‘SDL.rendererFlagPresentVSync’

src/FRP/Helm.hs:94:49: Not in scope: ‘SDL.rendererFlagAccelerated’

src/FRP/Helm.hs:131:59:
    Not in scope: ‘SDL.windowEventExposed’
    Perhaps you meant ‘SDL.windowEventEvent’ (imported from Graphics.UI.SDL)

src/FRP/Helm.hs:173:16: Not in scope: ‘SDL.textureAccessStreaming’

which seems to be correct because the sdl2 package does not have those functions in the 1.3 version. Weird that even with:

    sdl2 >= 1.1 && < 1.3,

it installed:

Installed sdl2-1.3.0

So finally, in order to make it work on Yosemite you have:

Install Homebrew and dependencies

Run the following commands:

$ brew doctor # if this is your first time using homebrew
$ brew install sdl2
$ brew install cairo --without-x11
$ brew install pango --without-x11
$ brew install gcc

Install the actual package

Run the following commands:

$ caban sandbox init
$ cabal install gtk2hs-buildtools
$ cabal install sdl2-1.2.0
$ cabal install helm-0.6.1 --with-gcc=gcc-4.9

And you should be fine.

If the last step ended up with SDL's errors, then you have check if a version of sdl2 has been installed that is > 1.2.* with cabal sandbox hc-pkg list if it has, then you need to run:

$ cabal install sdl2-1.2.0
$ cabal sandbox hc-pkg unregister <the sdl2 library that is > than 1.2.*, eg. sdl2-1.3.0>
$ cabal install helm-0.6.1 --with-gcc=gcc-4.9