无法使用Haskell的堆栈工具构建Yesod项目

时间:2016-07-28 19:59:43

标签: yesod haskell-stack

我最近一直在尝试使用stack创建一个Yesod项目,在他们的网站上给出了quick start

  1. 按照堆栈的安装说明进行堆栈。
  2. 创建新的脚手架网站:stack new my-project yesod-sqlite && cd my-project
  3. 安装yesod命令行工具:stack build yesod-bin cabal-install --install-ghc
  4. 构建库:stack build
  5. 启动开发服务器:stack exec -- yesod devel
  6. http://localhost:3000/
  7. 查看您的Yesod网站

    当我尝试stack build yesod-bin cabal-install --install-ghc时,我遇到的问题出现了,它说:

    <command line>: cannot satisfy -package Cabal-1.18.1.5
    (use -v for more information)
    Exit code ExitFailure 1 while running ["ghc","-clear-package-db","-global-package-db","-hide-all-packages","-package","base","-package","Cabal-1.18.1.5","/tmp/stack8413/Setup.hs","-o","/home/self/.stack/setup-exe-cache/x86_64-linux/tmp-setup-Simple-Cabal-1.18.1.5-ghc-7.10.3","-rtsopts"] in /tmp/stack8413/
    

    尝试使用-v旗帜带来这种美感:

    Version 1.1.2, Git revision cebe10e845fed4420b6224d97dcabf20477bbd4b (3646 commits) x86_64 hpack-0.14.0
    2016-07-28 16:44:34.775633: [debug] Checking for project config at: /home/self/my-project/stack.yaml @(stack_K1e6VSKnzs1HNYmTJGAgTQ:Stack.Config src/Stack/Config.hs:811:9)
    2016-07-28 16:44:34.776033: [debug] Loading project config file stack.yaml @(stack_K1e6VSKnzs1HNYmTJGAgTQ:Stack.Config src/Stack/Config.hs:829:13)
    2016-07-28 16:44:34.779083: [debug] Checking whether stack was built with libgmp4 @(stack_K1e6VSKnzs1HNYmTJGAgTQ:Stack.Config src/Stack/Config.hs:326:5)
    2016-07-28 16:44:34.779324: [debug] Run process: ldd /usr/bin/stack @(stack_K1e6VSKnzs1HNYmTJGAgTQ:System.Process.Read src/System/Process/Read.hs:283:3)
    2016-07-28 16:44:34.793798: [debug] Stack was not built with libgmp4 @(stack_K1e6VSKnzs1HNYmTJGAgTQ:Stack.Config src/Stack/Config.hs:330:14)
    2016-07-28 16:44:34.794072: [debug] Trying to decode /home/self/.stack/build-plan-cache/x86_64-linux/lts-6.9.cache @(stack_K1e6VSKnzs1HNYmTJGAgTQ:Data.Binary.VersionTagged src/Data/Binary/VersionTagged.hs:55:5)
    2016-07-28 16:44:34.832346: [debug] Success decoding /home/self/.stack/build-plan-cache/x86_64-linux/lts-6.9.cache @(stack_K1e6VSKnzs1HNYmTJGAgTQ:Data.Binary.VersionTagged src/Data/Binary/VersionTagged.hs:64:13)
    2016-07-28 16:44:34.832617: [debug] Getting system compiler version @(stack_K1e6VSKnzs1HNYmTJGAgTQ:Stack.Setup src/Stack/Setup.hs:341:17)
    2016-07-28 16:44:34.832839: [debug] Run process: ghc --info @(stack_K1e6VSKnzs1HNYmTJGAgTQ:System.Process.Read src/System/Process/Read.hs:283:3)
    2016-07-28 16:44:34.900832: [debug] Asking GHC for its version @(stack_K1e6VSKnzs1HNYmTJGAgTQ:Stack.Setup.Installed src/Stack/Setup/Installed.hs:94:13)
    2016-07-28 16:44:34.901074: [debug] Run process: ghc --numeric-version @(stack_K1e6VSKnzs1HNYmTJGAgTQ:System.Process.Read src/System/Process/Read.hs:283:3)
    2016-07-28 16:44:34.944872: [debug] Getting Cabal package version @(stack_K1e6VSKnzs1HNYmTJGAgTQ:Stack.GhcPkg src/Stack/GhcPkg.hs:165:5)
    2016-07-28 16:44:34.945501: [debug] Run process: ghc-pkg --no-user-package-db field --simple-output Cabal version @(stack_K1e6VSKnzs1HNYmTJGAgTQ:System.Process.Read src/System/Process/Read.hs:283:3)
    2016-07-28 16:44:34.974350: [debug] Resolving package entries @(stack_K1e6VSKnzs1HNYmTJGAgTQ:Stack.Setup src/Stack/Setup.hs:221:5)
    2016-07-28 16:44:34.975024: [debug] Getting global package database location @(stack_K1e6VSKnzs1HNYmTJGAgTQ:Stack.GhcPkg src/Stack/GhcPkg.hs:48:5)
    2016-07-28 16:44:34.975170: [debug] Run process: ghc-pkg --no-user-package-db list --global @(stack_K1e6VSKnzs1HNYmTJGAgTQ:System.Process.Read src/System/Process/Read.hs:283:3)
    2016-07-28 16:44:35.054707: [debug] Run process: ghc-pkg --global --no-user-package-db dump --expand-pkgroot @(stack_K1e6VSKnzs1HNYmTJGAgTQ:System.Process.Read src/System/Process/Read.hs:283:3)
    2016-07-28 16:44:35.146223: [debug] Ignoring package old-time due to wanting version 1.1.0.3 instead of 1.1.0.2 @(stack_K1e6VSKnzs1HNYmTJGAgTQ:Stack.Build.Installed src/Stack/Build/Installed.hs:189:5)
    2016-07-28 16:44:35.146521: [debug] Ignoring package haskeline due to wanting version 0.7.2.3 instead of 0.7.1.2 @(stack_K1e6VSKnzs1HNYmTJGAgTQ:Stack.Build.Installed src/Stack/Build/Installed.hs:189:5)
    2016-07-28 16:44:35.146669: [debug] Ignoring package terminfo due to wanting version 0.4.0.2 instead of 0.4.0.0 @(stack_K1e6VSKnzs1HNYmTJGAgTQ:Stack.Build.Installed src/Stack/Build/Installed.hs:189:5)
    2016-07-28 16:44:35.146817: [debug] Ignoring package transformers due to wanting version 0.4.2.0 instead of 0.3.0.0 @(stack_K1e6VSKnzs1HNYmTJGAgTQ:Stack.Build.Installed src/Stack/Build/Installed.hs:189:5)
    2016-07-28 16:44:35.146950: [debug] Ignoring package hoopl due to wanting version 3.10.0.2 instead of 3.10.0.1 @(stack_K1e6VSKnzs1HNYmTJGAgTQ:Stack.Build.Installed src/Stack/Build/Installed.hs:189:5)
    2016-07-28 16:44:35.147092: [debug] Ignoring package binary due to wanting version 0.7.5.0 instead of 0.7.1.0 @(stack_K1e6VSKnzs1HNYmTJGAgTQ:Stack.Build.Installed src/Stack/Build/Installed.hs:189:5)
    2016-07-28 16:44:35.147878: [debug] Ignoring package Cabal due to wanting version 1.22.8.0 instead of 1.18.1.5 @(stack_K1e6VSKnzs1HNYmTJGAgTQ:Stack.Build.Installed src/Stack/Build/Installed.hs:189:5)
    2016-07-28 16:44:35.148051: [debug] Ignoring package pretty due to wanting version 1.1.2.0 instead of 1.1.1.1 @(stack_K1e6VSKnzs1HNYmTJGAgTQ:Stack.Build.Installed src/Stack/Build/Installed.hs:189:5)
    2016-07-28 16:44:35.148183: [debug] Ignoring package hpc due to wanting version 0.6.0.2 instead of 0.6.0.1 @(stack_K1e6VSKnzs1HNYmTJGAgTQ:Stack.Build.Installed src/Stack/Build/Installed.hs:189:5)
    2016-07-28 16:44:35.148313: [debug] Ignoring package process due to wanting version 1.2.3.0 instead of 1.2.0.0 @(stack_K1e6VSKnzs1HNYmTJGAgTQ:Stack.Build.Installed src/Stack/Build/Installed.hs:189:5)
    2016-07-28 16:44:35.148442: [debug] Ignoring package directory due to wanting version 1.2.2.0 instead of 1.2.1.0 @(stack_K1e6VSKnzs1HNYmTJGAgTQ:Stack.Build.Installed src/Stack/Build/Installed.hs:189:5)
    2016-07-28 16:44:35.148589: [debug] Ignoring package unix due to wanting version 2.7.1.0 instead of 2.7.0.1 @(stack_K1e6VSKnzs1HNYmTJGAgTQ:Stack.Build.Installed src/Stack/Build/Installed.hs:189:5)
    2016-07-28 16:44:35.148720: [debug] Ignoring package time due to wanting version 1.5.0.1 instead of 1.4.2 @(stack_K1e6VSKnzs1HNYmTJGAgTQ:Stack.Build.Installed src/Stack/Build/Installed.hs:189:5)
    2016-07-28 16:44:35.148849: [debug] Ignoring package old-locale due to wanting version 1.0.0.7 instead of 1.0.0.6 @(stack_K1e6VSKnzs1HNYmTJGAgTQ:Stack.Build.Installed src/Stack/Build/Installed.hs:189:5)
    2016-07-28 16:44:35.149174: [debug] Ignoring package containers due to wanting version 0.5.6.2 instead of 0.5.5.1 @(stack_K1e6VSKnzs1HNYmTJGAgTQ:Stack.Build.Installed src/Stack/Build/Installed.hs:189:5)
    2016-07-28 16:44:35.149310: [debug] Ignoring package bytestring due to wanting version 0.10.6.0 instead of 0.10.4.0 @(stack_K1e6VSKnzs1HNYmTJGAgTQ:Stack.Build.Installed src/Stack/Build/Installed.hs:189:5)
    2016-07-28 16:44:35.149440: [debug] Ignoring package deepseq due to wanting version 1.4.1.1 instead of 1.3.0.2 @(stack_K1e6VSKnzs1HNYmTJGAgTQ:Stack.Build.Installed src/Stack/Build/Installed.hs:189:5)
    2016-07-28 16:44:35.149568: [debug] Ignoring package array due to wanting version 0.5.1.0 instead of 0.5.0.0 @(stack_K1e6VSKnzs1HNYmTJGAgTQ:Stack.Build.Installed src/Stack/Build/Installed.hs:189:5)
    2016-07-28 16:44:35.149698: [debug] Ignoring package filepath due to wanting version 1.4.0.0 instead of 1.3.0.2 @(stack_K1e6VSKnzs1HNYmTJGAgTQ:Stack.Build.Installed src/Stack/Build/Installed.hs:189:5)
    2016-07-28 16:44:35.149909: [debug] Run process: ghc-pkg --user --no-user-package-db --package-db /home/self/.stack/snapshots/x86_64-linux/lts-6.9/7.10.3/pkgdb dump --expand-pkgroot @(stack_K1e6VSKnzs1HNYmTJGAgTQ:System.Process.Read src/System/Process/Read.hs:283:3)
    2016-07-28 16:44:35.166946: [debug] Run process: ghc-pkg --user --no-user-package-db --package-db /home/self/my-project/.stack-work/install/x86_64-linux/lts-6.9/7.10.3/pkgdb dump --expand-pkgroot @(stack_K1e6VSKnzs1HNYmTJGAgTQ:System.Process.Read src/System/Process/Read.hs:283:3)
    2016-07-28 16:44:35.185054: [debug] Trying to decode /home/self/.stack/indices/Hackage/00-index.cache @(stack_K1e6VSKnzs1HNYmTJGAgTQ:Data.Binary.VersionTagged src/Data/Binary/VersionTagged.hs:55:5)
    2016-07-28 16:44:35.700635: [debug] Success decoding /home/self/.stack/indices/Hackage/00-index.cache @(stack_K1e6VSKnzs1HNYmTJGAgTQ:Data.Binary.VersionTagged src/Data/Binary/VersionTagged.hs:64:13)
    2016-07-28 16:44:36.305361: [debug] Creating process: /usr/bin/ghc -clear-package-db -global-package-db -hide-all-packages -package base -package Cabal-1.18.1.5 /tmp/stack8898/Setup.hs -o /home/self/.stack/setup-exe-cache/x86_64-linux/tmp-setup-Simple-Cabal-1.18.1.5-ghc-7.10.3 -rtsopts @(stack_K1e6VSKnzs1HNYmTJGAgTQ:System.Process.Run src/System/Process/Run.hs:102:5)
    <command line>: cannot satisfy -package Cabal-1.18.1.5
        (use -v for more information)
    2016-07-28 16:44:36.415789: [error] Exit code ExitFailure 1 while running ["ghc","-clear-package-db","-global-package-db","-hide-all-packages","-package","base","-package","Cabal-1.18.1.5","/tmp/stack8898/Setup.hs","-o","/home/self/.stack/setup-exe-cache/x86_64-linux/tmp-setup-Simple-Cabal-1.18.1.5-ghc-7.10.3","-rtsopts"] in /tmp/stack8898/ @(stack_K1e6VSKnzs1HNYmTJGAgTQ:System.Process.Run src/System/Process/Run.hs:70:13)
    

    当我在目录ls上执行/home/self/.stack/setup-exe-cache/x86_64-linux/时,它会显示一个空文件夹。 做stack setup

    stack will use the GHC on your PATH
    For more information on paths, see 'stack path' and 'stack exec env'
    To use this GHC and packages outside of a project, consider using:
    stack ghc, stack ghci, stack runghc, or stack exec
    

    我的开发环境基本上是Lubuntu,ghc 7.10.3和cabal 1.22.5.0。 我已经尝试重新安装stack:P。

    更新: 我运行stack build yesod-bin cabal-install --install-ghc --no-system-ghc,然后获取:

    Running /home/self/.stack/programs/x86_64-linux/ghc-7.10.3/bin/ghc-pkg --user --no-user-package-db --package-db /home/self/.stack/snapshots/x86_64-linux/lts-6.9/7.10.3/pkgdb dump --expand-pkgroot exited with ExitFailure 1
    ghc-pkg: /home/self/.stack/snapshots/x86_64-linux/lts-6.9/7.10.3/pkgdb/package.cache: GHC.PackageDb.readPackageDb: inappropriate type (not a ghc-pkg db file, wrong file magic number)
    

1 个答案:

答案 0 :(得分:3)

看起来您的全局GHC(通过apt安装的GHC)配置错误。你能尝试跑步吗?

stack build yesod-bin cabal-install --install-ghc --no-system-ghc

如果这样做,我建议:

  1. 删除已安装的系统GHC
  2. 修改堆栈配置以禁用系统GHC(请参阅the docs