运行 堆栈构建时如何解释此错误?

How to interpret this error when running stack build?

这是我所做的:

我 运行 stack build,但收到一个错误建议我向 stack.yaml 添加依赖项,所以我做了

extra-deps:                                                                                                                                                                                - Spock-0.13.0.0@sha256:163ef2698fed8f5801428d8dbe794fd126415a5ff3304b227750fdc4037497be,3745

运行 stack build 再次出现此错误:

Received ExitFailure 1 when running
Raw command: /home/agam/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.4/bin/ghc-pkg-8.8.4 --user --no-user-package-db --package-db /home/agam/.stack/snapshots/x86_64-linux-tinfo6/3932a3bb22be25146410341fc169e381513f21d026d12cb649688c6644f5c69c/8.8.4/pkgdb dump --expand-pkgroot
Standard error:

ghc-pkg: /home/agam/.stack/snapshots/x86_64-linux-tinfo6/3932a3bb22be25146410341fc169e381513f21d026d12cb649688c6644f5c69c/8.8.4/pkgdb/package.cache: GHC.PackageDb.readPackageDb: inappropriate type (not enough bytes)

我不确定如何解释此错误...“字节数不足”?

更新:尝试删除 ~/.stack,没有帮助:

➜ rm -rf ~/.stack
Preparing to install GHC (tinfo6) to an isolated location.
This will not interfere with any system-level installation.
Preparing to download ghc-tinfo6-8.8.4 ...
ghc-tinfo6-8.8.4: download has begun
ghc-tinfo6-8.8.4:    8.77 MiB / 198.61 MiB (  4.42%) downloaded...
ghc-tinfo6-8.8.4:   24.09 MiB / 198.61 MiB ( 12.13%) downloaded...
ghc-tinfo6-8.8.4:   39.31 MiB / 198.61 MiB ( 19.79%) downloaded...

...

ghc-tinfo6-8.8.4:  197.10 MiB / 198.61 MiB ( 99.24%) downloaded...
ghc-tinfo6-8.8.4:  198.61 MiB / 198.61 MiB (100.00%) downloaded...
Downloaded ghc-tinfo6-8.8.4.
Unpacking GHC into /home/agam/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.4.temp/ ...
Configuring GHC ...
Installing GHC ...
Installed GHC.

➜ stack build
Received ExitFailure 1 when running
Raw command: /home/agam/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.4/bin/ghc-pkg-8.8.4 --user --no-user-package-db --package-db /home/agam/code/simple-spock/.stack-work/install/x86_64-linux-tinfo6/3932a3bb22be25146410341fc169e381513f21d026d12cb649688c6644f5c69c/8.8.4/pkgdb dump --expand-pkgroot
Standard error:

ghc-pkg: /home/agam/code/simple-spock/.stack-work/install/x86_64-linux-tinfo6/3932a3bb22be25146410341fc169e381513f21d026d12cb649688c6644f5c69c/8.8.4/pkgdb/package.cache: GHC.PackageDb.readPackageDb: inappropriate type (not enough bytes)

这意味着您的 GHC 包数据库已损坏,是时候 rm -rf ~/.stack + 重建了。

我过去曾通过 运行 同时进行多个 Stack 操作来破坏它,但很难说你是怎么做到的。

接受前更新回答

  1. rm .stack-work
  2. rm -rf ~/.stack
  3. stack build