0

I started installing threadscope through stack (rather than cabal, is that OK? https://wiki.haskell.org/ThreadScope). threadscope requires cairo.

$ stack install cairo
cairo-0.13.3.1: configure

--  While building package cairo-0.13.3.1 using:
      /home/username/.stack/programs/x86_64-linux/ghc-8.0.1/bin/ghc --make -odir /tmp/stack13291/cairo-0.13.3.1/.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/setup -hidir /tmp/stack13291/cairo-0.13.3.1/.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/setup -i -i. -package=Cabal-1.24.2.0 -clear-package-db -global-package-db -package-db=/home/username/.stack/snapshots/x86_64-linux/lts-7.10/8.0.1/pkgdb /tmp/stack13291/cairo-0.13.3.1/Setup.hs /home/username/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs -main-is StackSetupShim.mainOverride -o /tmp/stack13291/cairo-0.13.3.1/.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/setup/setup -threaded
    Process exited with code: ExitFailure 1
    Logs have been written to: /home/username/.stack/global-project/.stack-work/logs/cairo-0.13.3.1.log

    [1 of 2] Compiling Main             ( /tmp/stack13291/cairo-0.13.3.1/Setup.hs, /tmp/stack13291/cairo-0.13.3.1/.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/setup/Main.o )

    /tmp/stack13291/cairo-0.13.3.1/Setup.hs:8:29: error:
        • Couldn't match expected type ‘Distribution.Simple.UserHooks.UserHooks’
                      with actual type ‘Cabal-1.24.1.0:Distribution.Simple.UserHooks.UserHooks’
          NB: ‘Cabal-1.24.1.0:Distribution.Simple.UserHooks.UserHooks’
                is defined in ‘Distribution.Simple.UserHooks’
                    in package ‘Cabal-1.24.1.0’
              ‘Distribution.Simple.UserHooks.UserHooks’
                is defined in ‘Distribution.Simple.UserHooks’
                    in package ‘Cabal-1.24.2.0’
        • In the first argument of ‘defaultMainWithHooks’, namely
            ‘gtk2hsUserHooks’
          In the expression: defaultMainWithHooks gtk2hsUserHooks
          In an equation for ‘main’:
              main = defaultMainWithHooks gtk2hsUserHooks

And chasing further, I tried to install gtk build tools:

$ stack install gtk2hs-buildtools
Copying from /home/username/.stack/snapshots/x86_64-linux/lts-7.10/8.0.1/bin/gtk2hsC2hs to /home/username/.local/bin/gtk2hsC2hs
Copying from /home/username/.stack/snapshots/x86_64-linux/lts-7.10/8.0.1/bin/gtk2hsHookGenerator to /home/username/.local/bin/gtk2hsHookGenerator
Copying from /home/username/.stack/snapshots/x86_64-linux/lts-7.10/8.0.1/bin/gtk2hsTypeGen to /home/username/.local/bin/gtk2hsTypeGen

Copied executables to /home/username/.local/bin:
- gtk2hsC2hs
- gtk2hsHookGenerator
- gtk2hsTypeGen

I kept getting the same error for cairo installation. I'm running Ubuntu 14.04 and do have libcairo2-dev installed:

$ stack install threadscope
glib-0.13.4.1: configure
cairo-0.13.3.1: configure
Progress: 2/6
--  While building package cairo-0.13.3.1 using:
      /home/username/.stack/programs/x86_64-linux/ghc-8.0.1/bin/ghc --make -odir /tmp/stack20456/cairo-0.13.3.1/.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/setup -hidir /tmp/stack20456/cairo-0.13.3.1/.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/setup -i -i. -package=Cabal-1.24.2.0 -clear-package-db -global-package-db -package-db=/home/username/.stack/snapshots/x86_64-linux/lts-7.10/8.0.1/pkgdb /tmp/stack20456/cairo-0.13.3.1/Setup.hs /home/username/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs -main-is StackSetupShim.mainOverride -o /tmp/stack20456/cairo-0.13.3.1/.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/setup/setup -threaded
    Process exited with code: ExitFailure 1

Stack version:

$ stack --version
Version 1.3.2, Git revision 3f675146590da4f3edf768b89355f798229da2a5 (4395 commits) x86_64 hpack-0.15.0

Cabal version:

$ stack exec cabal -- --version
cabal-install version 1.24.0.1
compiled using version 1.24.1.0 of the Cabal library 

Other versions:

$ sudo apt-get install libgtk2.0-dev libpango1.0-dev libglib2.0-dev libcairo2-dev libghc-gtk-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libcairo2-dev is already the newest version.
libglib2.0-dev is already the newest version.
libglib2.0-dev set to manually installed.
libgtk2.0-dev is already the newest version.
libgtk2.0-dev set to manually installed.
libpango1.0-dev is already the newest version.
libpango1.0-dev set to manually installed.
libghc-gtk-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove

The reason I raise this here rather than superuser or ubuntu is that this error:

  • Couldn't match expected type ‘Distribution.Simple.UserHooks.UserHooks’
                  with actual type ‘Cabal-1.24.1.0:Distribution.Simple.UserHooks.UserHooks’

Does seem to suggest there's something funky with the Haskell package code itself expecting this to be within a module that is somehow one level deeper, inside the cabal-*:, right?

Other references that haven't cleared it up:

Community
  • 1
  • 1
Mittenchops
  • 18,633
  • 33
  • 128
  • 246
  • 1
    Can you try installing the development version of Stack (via `stack upgrade --git --source-only`)? There's support for the new `custom-setup` stuff in Cabal in the newest version. Also, `stack setup --upgrade-cabal` may help by providing the latest Cabal library, but is probably not necessary. – Michael Snoyman Jan 29 '17 at 12:51
  • Thanks, @MichaelSnoyman. Is there documentation for the new custom-setup stuff? Googling only gave me github bug reports. Also, the first error I got after executing `stack upgrade --git --source-only` was `Cabal file warning in /tmp/stack-upgrade25291/stack/stack.cabal: Ignoring unknown section type: custom-setup` which does not bode well. – Mittenchops Jan 30 '17 at 02:47
  • @MichaelSnoyman, I installed with `stack upgrade --git --source-only` and still get the same errors in installing cairo, threadscope, and gtk2hs-buildtools. – Mittenchops Jan 30 '17 at 03:14
  • This appears to be the official [custom-setup documentation](https://www.haskell.org/cabal/users-guide/developing-packages.html#custom-setup-scripts). It's part of Cabal, not Stack. Regarding the Stack upgrade: can you confirm what `stack --version` now says? – Michael Snoyman Jan 30 '17 at 12:21
  • `$ stack --version Version 1.3.2, Git revision 3f675146590da4f3edf768b89355f798229da2a5 (4395 commits) x86_64 hpack-0.15.0` Huh. It did a bunch of installing when I ran that git command, but this is identical to the version I had beforehand. – Mittenchops Jan 31 '17 at 03:38
  • 1
    I'm gonna guess you don't have ~/.local/bin in your $PATH. You should have gotten a warning message about that during the upgrade. Can you try running `~/.local/bin/stack --version`? And then try `~/.local/bin/stack build cairo`? – Michael Snoyman Jan 31 '17 at 03:59
  • 1
    Ughhhh, I had /home/username/.cabal/bin/ on my path first... Completely, contravening your orders in: https://docs.haskellstack.org/en/stable/install_and_upgrade/#upgrade and https://github.com/commercialhaskell/stack/issues/237#issuecomment-126793301 Thanks @MichaelSnoyman. – Mittenchops Jan 31 '17 at 04:16
  • Awesome, glad it worked. I'll create an answer shortly. – Michael Snoyman Jan 31 '17 at 06:13

2 Answers2

1

I think this is the same problem I have recently

Could you try

stack setup --upgrade-cabal

and see if it fix the problem.

== Edit: ==

However, to answer your first question, I can install threadscope via stack with following command,

$ stack --resolver=nightly install threadscope
Selected resolver: nightly-2017-01-31
Copying from /home/wizzup/.stack/global-project/.stack-work/install/x86_64-linux-ncurses6/nightly-2017-01-31/8.0.2/bin/threadscope to /home/wizzup/.local/bin/threadscope

Copied executables to /home/wizzup/.local/bin/:
- threadscope

but I am using Arch Linux.

wizzup
  • 2,361
  • 20
  • 34
  • `$ stack setup --upgrade-cabal Currently installed Cabal is 1.24.2.0, newest is 1.24.2.0. I'm not upgrading Cabal.` – Mittenchops Jan 31 '17 at 03:36
1

In order to compile cairo successfully, you'll need support for the new custom-setup feature in Cabal 1.24. The officially released Stack version does not support this yet, but support is available on master. In order to install it:

  • Run stack upgrade --git --source-only
  • Ensure that the destination directory (usually $HOME/.local/bin) is on your PATH
  • To be extra sure, run stack --version and which stack

After this, stack build cairo should work.

Michael Snoyman
  • 31,100
  • 3
  • 48
  • 77