9

I'm starting a new project that will hopefully use gtk2hs. However, I can not get this package to install on my fairly typical Linux box. Here is the failure :

[1 of 2] Compiling SetupWrapper     ( /tmp/cairo-0.12.4-4201/cairo-0.12.4/SetupWrapper.hs, /tmp/cairo-0.12.4-4201/cairo-0.12.4/dist/dist-sandbox-58b5f9c6/setup/SetupWrapper.o )

/tmp/cairo-0.12.4-4201/cairo-0.12.4/SetupWrapper.hs:94:45:
    Ambiguous occurrence `moreRecentFile'
    It could refer to either `SetupWrapper.moreRecentFile',
                             defined at /tmp/cairo-0.12.4-4201/cairo-0.12.4/SetupWrapper.hs:149:1
                          or `Distribution.Simple.Utils.moreRecentFile',
                             imported from `Distribution.Simple.Utils' at /tmp/cairo-0.12.4-4201/cairo-0.12.4/SetupWrapper.hs:8:1-32

/tmp/cairo-0.12.4-4201/cairo-0.12.4/SetupWrapper.hs:95:45:
    Ambiguous occurrence `moreRecentFile'
    It could refer to either `SetupWrapper.moreRecentFile',
                             defined at /tmp/cairo-0.12.4-4201/cairo-0.12.4/SetupWrapper.hs:149:1
                          or `Distribution.Simple.Utils.moreRecentFile',
                             imported from `Distribution.Simple.Utils' at /tmp/cairo-0.12.4-4201/cairo-0.12.4/SetupWrapper.hs:8:1-32
Failed to install cairo-0.12.4
[1 of 2] Compiling SetupWrapper     ( /tmp/glib-0.12.4-4201/glib-0.12.4/SetupWrapper.hs, /tmp/glib-0.12.4-4201/glib-0.12.4/dist/dist-sandbox-58b5f9c6/setup/SetupWrapper.o )

/tmp/glib-0.12.4-4201/glib-0.12.4/SetupWrapper.hs:94:45:
    Ambiguous occurrence `moreRecentFile'
    It could refer to either `SetupWrapper.moreRecentFile',
                             defined at /tmp/glib-0.12.4-4201/glib-0.12.4/SetupWrapper.hs:149:1
                          or `Distribution.Simple.Utils.moreRecentFile',
                             imported from `Distribution.Simple.Utils' at /tmp/glib-0.12.4-4201/glib-0.12.4/SetupWrapper.hs:8:1-32

/tmp/glib-0.12.4-4201/glib-0.12.4/SetupWrapper.hs:95:45:
    Ambiguous occurrence `moreRecentFile'
    It could refer to either `SetupWrapper.moreRecentFile',
                             defined at /tmp/glib-0.12.4-4201/glib-0.12.4/SetupWrapper.hs:149:1
                          or `Distribution.Simple.Utils.moreRecentFile',
                             imported from `Distribution.Simple.Utils' at /tmp/glib-0.12.4-4201/glib-0.12.4/SetupWrapper.hs:8:1-32
Failed to install glib-0.12.4

It seems to be related to recent cabal versions, since that used to work before. It seems to be a known bug (http://trac.haskell.org/gtk2hs/ticket/1292 , http://trac.haskell.org/gtk2hs/ticket/1291 and http://trac.haskell.org/gtk2hs/ticket/1289), however it has not moved for weeks. I am not sufficiently competent to suggest a good fix, so I would like your advice. This is very annoying since I am stuck on this important project, and it pains me to think that the main GUI lib of our language has been broken for many weeks now.

cabal-install version 1.18.0.2 using version 1.18.1.1 of the Cabal library / ghc 7.4.1

Thanks for your help

Paul R
  • 747
  • 4
  • 13
  • 2
    You can edit `Setup.hs` and change it to use explicit imports. – Mikhail Glushenkov Oct 24 '13 at 16:32
  • 1
    You can see from your error message that the issue is in the `cairo` package, in the file `SetupWrapper.hs`, which defines the function `moreRecentFile` but also imports a function of the same name from `Distribution.Simple.Utils` (part of the cabal library). Presumably that's a new function added to cabal since the `cairo` package was tested. [Here](http://www.mail-archive.com/gtk2hs-devel@lists.sourceforge.net/msg01338.html) is a patch I found with a quick google search; don't know the status. – jberryman Oct 24 '13 at 16:55
  • Thank you. Indeed the root of the problem is easy to fix. I have never used setup.hs files, I guess that confused me. I will probably take this path, and maybe try to get that fixed upstream. – Paul R Oct 25 '13 at 06:21

2 Answers2

3

The correct solution for now is to build from darcs. Detailed instructions are given in the Getting the latest and greatest section of the installation instructions; the short version is:

darcs get --lazy http://code.haskell.org/gtk2hs
cd gtk2hs
sh bootstrap.sh

EDIT: The official 0.12.5 release of gtk2hs from December 2013 supports cabal 1.18, so the above darcs instructions are no longer needed. The full installation instructions are still available from the Gtk2Hs download page; the short version is:

cabal install gtk2hs-buildtools
cabal install gtk gtk3
Daniel Wagner
  • 145,880
  • 9
  • 220
  • 380
  • Thank you Daniel. I am new to gtk2hs, do you know if they plan a bugfix release on Hackage soon ? Part of my motivation by coming here is to get that fixed for everyone, not just for me. Regards, – Paul R Oct 25 '13 at 06:25
  • when doing this I get : "At least the following dependencies are missing: cairo >=0.12.0 && <0.13" plus a bunch of other missing dependencies. – Jeremy Knees Oct 28 '13 at 17:04
  • 1
    @JeremyKnees Please open a new question with the full details. Exactly what you tried, full error output, etc. Trying to cram all the relevant information into a comment is going to just be painful and unreadable. – Daniel Wagner Oct 28 '13 at 17:18
  • This is the way to go until the fix is released to hackage. For people using cabal sandbox, I recommand making a "bootstrap-sandbox" from the bootstrap.hs file, **sharing the same sandbox** for all pacakges so that they build fine. Thank you Daniel. – Paul R Oct 29 '13 at 14:45
  • hi @DanielWagner. Please could you help me understand what is blocking the release of a fixed version to Hackage ? Thank you – Paul R Nov 15 '13 at 13:45
  • @PaulR I am dealing with depression, which makes it difficult for me to focus on my professional duties. – Daniel Wagner Nov 20 '13 at 02:37
  • @DanielWagner I am sorry to read this, and I hope you will be back on your feet soon, strong. Life is a wonderful gift, in particular for smart people in peaceful countries. You are young and your life is so promising, so exciting. Take a break off keyboard, listen to good reggae music (loud), go out and drink beer with mates. Give your brain a good wash and treat yourself with much kindness. Time flies, enjoy it :D – Paul R Nov 21 '13 at 09:51
  • @Paul, can you explain how to share this as a sandbox ? I don't see any bootstrap.hs file... – miguel.negrao Dec 18 '13 at 09:30
  • @miguel.negrao : a fixed version of Gtk2hs has now been released to hackage (gtk 0.12.5). Daniel could update its answer to reflect it, or maybe I could. You can build it with cabal sandbox : 1) install gtk2hs-builddeps, 2) add the sandbox bin dir to your path, 3) install gtk . Cheers – Paul R Dec 19 '13 at 09:50
  • @PaulR It seems other folks have rejected your edit, which as far as I can tell was spot on. So that's a bit obnoxious. I'm going to apply your edit by hand (which means it will officially say I made the edit instead of you -- I hope that's okay). – Daniel Wagner Dec 19 '13 at 16:28
2

You can try with older Cabal version using cabal install --cabal-lib-version=1.16.0 gtk.

Yuras
  • 13,856
  • 1
  • 45
  • 58
  • @jozefg it says `cabal-install` what `Cabal` version it should use to compile `Setup.hs`. It will help because `moreRecentFile` doesn't exist in `Cabal-1.16.0`. The issue with `moreRecentFile` is not the only one, I tried to install `gtk2hs` few weeks ago, and the `--cabal-lib-version` trick was the easiest solution I found. – Yuras Oct 24 '13 at 18:29
  • Thank you Yuras for this tip. I might use it if I am really in a hurry, however my primary goal now is to get that sorted and fixed for everyone. – Paul R Oct 25 '13 at 06:19