Building project dependent on gtk2hs fails on lts-7.8 and later

荒凉一梦 提交于 2019-12-10 23:46:14

问题


Building project dependent on glib fails on lts-7.8 and later after Cabal becomes 1.24.1.0.

Steps to reproduce

  1. Add glib to a project's .cabal file

    build-depends:       base
                       , gtktest
                       , glib
    
  2. Run following commands

    stack install gtk2hs-buildtools
    stack build
    

Result

The following error occurred

...

[debug] Ignoring package Cabal due to wanting version 1.24.1.0 instead of 1.24.0.0
@(Stack\Build\Installed.hs:196:5)

...

--  While building package glib-0.13.4.1 using:
  C:\Users\foo\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.1\bin\ghc.EXE --make -odir C:\Users\foo\AppData\Local\Temp\stack5512\glib-0.13.4.1\.stack-work\dist\b7fec021\setup -hidir C:\Users\foo\AppData\Local\Temp\stack5512\glib-0.13.4.1\.stack-work\dist\b7fec021\setup -i -i. -package=Cabal-1.24.0.0 -clear-package-db -global-package-db -package-db=C:\sr\snapshots\a78c6a89\pkgdb C:\Users\foo\AppData\Local\Temp\stack5512\glib-0.13.4.1\Setup.hs -o C:\Users\foo\AppData\Local\Temp\stack5512\glib-0.13.4.1\.stack-work\dist\b7fec021\setup\setup
Process exited with code: ExitFailure 1
Logs have been written to: C:\Users\foo\Documents\Files\Haskell\gtktest\.stack-work\logs\glib-0.13.4.1.log

[1 of 1] Compiling Main             ( C:\Users\foo\AppData\Local\Temp\stack5512\glib-0.13.4.1\Setup.hs, C:\Users\foo\AppData\Local\Temp\stack5512\glib-0.13.4.1\.stack-work\dist\b7fec021\setup\Main.o )

C:\Users\foo\AppData\Local\Temp\stack5512\glib-0.13.4.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.0.0’
     In the first argument of ‘defaultMainWithHooks’, namely
        gtk2hsUserHooks’
      In the expression: defaultMainWithHooks gtk2hsUserHooks
      In an equation for ‘main’:
          main = defaultMainWithHooks gtk2hsUserHooks

I thought that Cabal-1.24.0.0 in the ghc-8.0.1 global package was causing problems, and succeeded building it after installing Cabal-1.24.1.0 in ghc 's global package.

However, this method is difficult for beginners and I do not think the right solution. How is the correct way to solve it?

Stack version

Version 1.2.0, Git revision 123819b7d65df2ad7fe63fb5eb39a98536acb5f3 (4055 commits) x86_64 hpack-0.14.0

来源:https://stackoverflow.com/questions/40659148/building-project-dependent-on-gtk2hs-fails-on-lts-7-8-and-later

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!