5

I've installed gtk2hs-buildtools with no problem, but here's the output when I try to install gtk using 'cabal install gtk':

[gautam@gautam ~]$ cabal install gtk
Resolving dependencies...
[1 of 2] Compiling SetupWrapper     ( /tmp/cairo-0.12.213784/cairo-0.12.2/SetupWrapper.hs, /tmp/cairo-0.12.213784/cairo-0.12.2/dist/setup/SetupWrapper.o )
[2 of 2] Compiling Main             ( /tmp/cairo-0.12.213784/cairo-0.12.2/Setup.hs, /tmp/cairo-0.12.213784/cairo-0.12.2/dist/setup/Main.o )
Linking /tmp/cairo-0.12.213784/cairo-0.12.2/dist/setup/setup ...
[1 of 2] Compiling Gtk2HsSetup      ( Gtk2HsSetup.hs, dist/setup-wrapper/Gtk2HsSetup.o )
[2 of 2] Compiling Main             ( SetupMain.hs, dist/setup-wrapper/Main.o )
Linking dist/setup-wrapper/setup ...
Cannot find gtk2hsC2hs
Please install `gtk2hs-buildtools` first and check that the install directory is in your PATH (e.g. HOME/.cabal/bin).
[1 of 2] Compiling SetupWrapper     ( /tmp/glib-0.12.213784/glib-0.12.2/SetupWrapper.hs, /tmp/glib-0.12.213784/glib-0.12.2/dist/setup/SetupWrapper.o )
[2 of 2] Compiling Main             ( /tmp/glib-0.12.213784/glib-0.12.2/Setup.hs, /tmp/glib-0.12.213784/glib-0.12.2/dist/setup/Main.o )
Linking /tmp/glib-0.12.213784/glib-0.12.2/dist/setup/setup ...
[1 of 2] Compiling Gtk2HsSetup      ( Gtk2HsSetup.hs, dist/setup-wrapper/Gtk2HsSetup.o )
[2 of 2] Compiling Main             ( SetupMain.hs, dist/setup-wrapper/Main.o )
Linking dist/setup-wrapper/setup ...
Cannot find gtk2hsC2hs
Please install `gtk2hs-buildtools` first and check that the install directory is in your PATH (e.g. HOME/.cabal/bin).
cabal: Error: some packages failed to install:
cairo-0.12.2 failed during the configure step. The exception was:
ExitFailure 1
gio-0.12.2 depends on glib-0.12.2 which failed to install.
glib-0.12.2 failed during the configure step. The exception was:
ExitFailure 1
gtk-0.12.2 depends on glib-0.12.2 which failed to install.
pango-0.12.2 depends on glib-0.12.2 which failed to install.
[gautam@gautam ~]$ 

This problem occurs on both my Mac and in my Fedora VM. Does anybody know how to fix this? Thanks!

Simeon Visser
  • 118,920
  • 18
  • 185
  • 180
Gautam
  • 1,732
  • 4
  • 18
  • 26

1 Answers1

10

You need to add the path in which the Gtk2Hs build tools are stored to your $PATH environment variable, so that the build process can find them. On Linux, it's $HOME/.cabal/bin. On OS X, it's $HOME/Library/Haskell/bin (although that might just be if you're using the Haskell Platform — if that doesn't work, try $HOME/.cabal/bin).

To add a directory to your $PATH, run export PATH=directory:$PATH. You should probably add this to your shell's startup file (it depends on your shell and OS — probably either ~/.bashrc, ~/.profile or ~/.bash_profile). (You'll need to do so if you want to run any programs you install with cabal directly, anyway.)

ehird
  • 40,602
  • 3
  • 180
  • 182
  • Thanks for the explanation. I have added $Home/cabal/bin to my $PATH in Fedora, but it didn't fix the problem. Where are ~/.profile and ~/.bash_profile, and how do I edit them? – Gautam Apr 03 '12 at 02:01
  • 1
    Note also: make sure you use `$HOME/.cabal/bin` and not `~/.cabal/bin` or it won't work. – ivanm Apr 03 '12 at 03:26
  • @ivanm: Works for me: `$ PATH=~/.cabal/bin xmonad --version` → `xmonad 0.10`. – ehird Apr 03 '12 at 03:35
  • @ehird: it won't work if you install happy, alex, etc. with cabal-install and then try building something that wants them as a build-tool; `~/` is expanded by the shell, and thus cabal-install won't do it and can't find that directory. – ivanm Apr 03 '12 at 05:21
  • +1 for giving the Mac path. So much of the online docs talk about `~/.cabal`, which of course doesn't exist, but since so few talk about it, you start second guessing yourself, searching it out... :) – Warren Young Oct 08 '13 at 03:09
  • I do "export PATH=$HOME/.cabal/bin:$PATH" and then "cabal install gtk" . Still get same error as mentioned by first post. What am I doing wrong? – Jeremy Knees Oct 19 '13 at 08:58
  • I have $HOME/.cabal/bin in $PATH, but cabal still can't find gtk2hsC2hs -- Solved it: Don't call cabal with sudo. – PSchwede Feb 01 '14 at 09:13