首页 > 解决方案 > ghc-pkg:无法打开数据库进行修改:hLock:无效参数

问题描述

我正在尝试behead.hs从 Ubuntu 20.04 (WSL1) 上的 pandoc 教程编译脚本。
stack exec -- ghc behead.hs我可以使用or成功编译它,
stack --resolver lts-16.25 exec -- ghc behead.hs
pandoc-types-1.20我需要它,pandoc-types-1.22所以我尝试
stack --resolver nightly-2020-12-07 exec -- ghc behead.hs
(最早的夜间功能pandoc-types-1.222020-09-20,失败并出现与以下相同的错误)

这产生:

Preparing to install GHC (tinfo6) to an isolated location.
This will not interfere with any system-level installation.
Already downloaded.
ghc-pkg: Couldn't open database /home/me/.stack/programs/x86_64-linux/ghc-tinfo6-8.10.2/lib/ghc-8.10.2/package.conf.d for modification: {handle: /home/me/.stack/programs/x86_64-linux/ghc-tinfo6-8.10.2/lib/ghc-8.10.2/package.conf.d/package.cache.lock}: hLock: invalid argument (Invalid argument)
make[1]: *** [ghc.mk:973: install_packages] Error 1
make: *** [Makefile:51: install] Error 2
Received ExitFailure 2 when running
Raw command: /usr/bin/make install
Run from: /home/me/.stack/programs/x86_64-linux/ghc-tinfo6-8.10.2.temp/ghc-8.10.2/


Error: Error encountered while installing GHC with
         make install
         run in /home/me/.stack/programs/x86_64-linux/ghc-tinfo6-8.10.2.temp/ghc-8.10.2/

       The following directories may now contain files, but won't be used by stack:
         - /home/me/.stack/programs/x86_64-linux/ghc-tinfo6-8.10.2.temp/
         - /home/me/.stack/programs/x86_64-linux/ghc-tinfo6-8.10.2/

       For more information consider rerunning with --verbose flag

Installing GHC ...

由于--verbose我在这里粘贴的内容太多,但我很高兴提供 grep 结果。可能相关的摘录:

#the WSL doesn't seem to get recognized as ubuntu
[debug] checking build system type... x86_64-pc-linux-gnu
2020-12-08 11:40:58.363496: [debug] checking host system type... x86_64-pc-linux-gnu
2020-12-08 11:40:58.363926: [debug] checking target system type... x86_64-pc-linux-gnu
2020-12-08 11:40:58.364331: [debug] Build platform inferred as: x86_64-unknown-linux
2020-12-08 11:40:58.412992: [debug] Host platform inferred as: x86_64-unknown-linux
2020-12-08 11:40:58.463758: [debug] Target platform inferred as: x86_64-unknown-linux
2020-12-08 11:40:58.715901: [debug] GHC build  : x86_64-unknown-linux
2020-12-08 11:40:58.716483: [debug] GHC host   : x86_64-unknown-linux
2020-12-08 11:40:58.717018: [debug] GHC target : x86_64-unknown-linux
2020-12-08 11:40:58.717558: [debug] LLVM target: x86_64-unknown-linux
#the last lines before the error:
[debug] Installing library in /home/me/.stack/programs/x86_64-linux/ghc-tinfo6-8.10.2/lib/ghc-8.10.2/ghc-8.10.2
[debug] "/home/me/.stack/programs/x86_64-linux/ghc-tinfo6-8.10.2/lib/ghc-8.10.2/bin/ghc-pkg" --force --global-package-db "/home/me/.stack/programs/x86_64-linux/ghc-tinfo6-8.10.2/lib/ghc-8.10.2/package.conf.d" update rts/dist/package.conf.install

我目前无法在实际的 linux 机器上重现它,以查看我使用 WSL 的事实是否与问题相关。我可以在〜6小时内尝试。

复制文件:

#!/usr/bin/env runhaskell
-- behead.hs
import Text.Pandoc.JSON

main :: IO ()
main = toJSONFilter behead

behead :: Block -> Block
behead (Header n _ xs) | n >= 2 = Para [Emph xs]

我想了解为什么会发生这种情况,但更重要的是如何使用pandoc-types-1.22.

标签: haskellwindows-subsystem-for-linuxpandochaskell-stackghc-pkg

解决方案


我在 WSL 上也遇到了同样的问题,并通过升级 Ubuntu 发行版以使用 WSL2 解决了这个问题。https://docs.microsoft.com/en-us/windows/wsl/install-win10


推荐阅读