1

I am trying to install the diagrams package. If I do

cabal install diagrams

I get (towards the end)

Configuring lens-4.2...
Building lens-4.2...
Preprocessing library lens-4.2...

src/Control/Lens/Internal/Zoom.hs:47:8:
    Could not find module `Control.Monad.Trans.Except'
    It is a member of the hidden package `transformers-0.4.1.0'.
    Perhaps you need to add `transformers' to the build-depends in your .cabal file.
    Use -v to see a list of the files searched for.
Failed to install lens-4.2
cabal: Error: some packages failed to install:
diagrams-1.2 depends on lens-4.2 which failed to install.
diagrams-contrib-1.1.2 depends on lens-4.2 which failed to install.
diagrams-core-1.2.0.1 depends on lens-4.2 which failed to install.
diagrams-lib-1.2.0.1 depends on lens-4.2 which failed to install.
diagrams-svg-1.1 depends on lens-4.2 which failed to install.
force-layout-0.3.0.4 depends on lens-4.2 which failed to install.
lens-4.2 failed during the building phase. The exception was:
ExitFailure 1

So then I try

$cabal install lens transformers diagrams

And I get (towards the end)

In-place registering diagrams-lib-1.2.0.1...
Installing library in /home/theking/.cabal/lib/diagrams-lib-1.2.0.1/ghc-7.6.3
Registering diagrams-lib-1.2.0.1...
Installed diagrams-lib-1.2.0.1
cabal: Error: some packages failed to install:
cairo-0.12.5.3 failed during the configure step. The exception was:
ExitFailure 1
diagrams-0.3 depends on glib-0.12.5.4 which failed to install.
diagrams-cairo-1.2 depends on glib-0.12.5.4 which failed to install.
glib-0.12.5.4 failed during the configure step. The exception was:
ExitFailure 1
pango-0.12.5.3 depends on glib-0.12.5.4 which failed to install.

So I tried one more thing

$ cabal install glib
Resolving dependencies...
[1 of 2] Compiling SetupWrapper     ( /tmp/glib-0.12.5.4-9179/glib-0.12.5.4/SetupWrapper.hs, /tmp/glib-0.12.5.4-9179/glib-0.12.5.4/dist/setup/SetupWrapper.o )
[2 of 2] Compiling Main             ( /tmp/glib-0.12.5.4-9179/glib-0.12.5.4/Setup.hs, /tmp/glib-0.12.5.4-9179/glib-0.12.5.4/dist/setup/Main.o )
Linking /tmp/glib-0.12.5.4-9179/glib-0.12.5.4/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 ...
Configuring glib-0.12.5.4...
setup: The program gtk2hsC2hs version >=0.13.8 is required but the version
found at /usr/bin/gtk2hsC2hs is version 0.13.6
Failed to install glib-0.12.5.4
cabal: Error: some packages failed to install:
glib-0.12.5.4 failed during the configure step. The exception was:
ExitFailure 1

And I got stuck here. So how do I install diagrams. I don't really care how it gets installed (getting a little fed up with cabal) as long as it gets installed.

The awesome stuff this package does

Notes: I am on linux. I also tried cabal install gtk2hs-buildtools.

duplode
  • 33,731
  • 7
  • 79
  • 150
PyRulez
  • 10,513
  • 10
  • 42
  • 87
  • there's instructions here http://www.haskell.org/haskellwiki/Diagrams/Install maybe you're missing a dll or something? – Rachel Gallen Jun 09 '14 at 22:44
  • Did you install gtk-buildtools first? – Thomas M. DuBuisson Jun 09 '14 at 23:00
  • @RachelGallen My first line was the instructions. I am on linux. – PyRulez Jun 09 '14 at 23:36
  • Not that it should really be an issue, but... what GHC and cabal versions are you using? Updating those and installing really recent versions of all packages might make things easier. – leftaroundabout Jun 10 '14 at 00:07
  • 1
    The second error block for some reason mentions `diagrams-0.3`. I have no idea why that happens, but you surely don't want anything to do with such an old version. In fact, recent versions of `diagrams` don't even depend on Cairo, Pango and GTK, as `diagrams-cairo` is now a separate package. Try specifying the version of `diagrams`, as in `cabal install diagrams-1.2`. You can also add the `--dry-run` flag to confirm that it won't require the Cairo dependencies before actually attempting the install. – duplode Jun 10 '14 at 00:29
  • 1
    What does `type -a gtk2hsC2hs` say? Is cabal's executable installation directory in your `PATH`? – Daniel Wagner Jun 10 '14 at 00:29
  • 1
    @duplode That worked. If you make it an answer, I will tick it. – PyRulez Jun 10 '14 at 15:59

1 Answers1

2

The second error block says that:

diagrams-0.3 depends on glib-0.12.5.4 which failed to install.

diagrams-0.3 is a very old version of diagrams, and in normal circumstances cabal shouldn't be trying to install it. Recent versions of diagrams do not even depend on diagrams-cairo, so as long as you don't need the Cairo backend you can work around the Cairo/GTK issues by asking for the current version of diagrams, as in:

cabal install diagrams-1.2

Ideally, it would be good to find out why your cabal is pulling the old version. cabal install diagrams --dry-run (which only show the packages that would be pulled without actually installing them) and ghc-pkg list (which shows the packages currently in your system) might help figuring that out.

As for the Cairo-related issues, as Daniel Wagner suggests a PATH issue might be preventing cabal from using the latest versions of the gtk2hs-buildtools you have installed. For instance, you might have a global installation of the tools, which is overriding the local one you have done with cabal. ghc-pkg list allows you to verify that. Also, check this relevant question.

Community
  • 1
  • 1
duplode
  • 33,731
  • 7
  • 79
  • 150