ghc-pkg: Couldn't open database for modification: hLock: invalid argument
Asked Answered
S

1

7

I'm trying to compile the behead.hs script from the pandoc tutorial on Ubuntu 20.04 (WSL1). I can successfully compile it with
stack exec -- ghc behead.hs or
stack --resolver lts-16.25 exec -- ghc behead.hs
but that uses pandoc-types-1.20 and I need pandoc-types-1.22 so I try
stack --resolver nightly-2020-12-07 exec -- ghc behead.hs
(the earliest nightly to feature pandoc-types-1.22 is 2020-09-20, that fails with the same error as below)

This yields:

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 ...

With --verbose I get too much to paste here, but I am happy to provide grep results. Possibly relevant extract:

#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

I have currently no way of reproducing this on an actual linux machine to see whether the fact that I'm using WSL is relevant to the problem. I can try that in ~6h.

File for reproduction:

#!/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]

I would like to understand why this happens but morover how I can compile the script with pandoc-types-1.22.

Synn answered 8/12, 2020 at 10:49 Comment(4)
sounds like a filesystem lock on the file? have you tried restarting your computer?Forebode
@Forebode Good point, I just tried it but sadly the error persistsSynn
you can always do the nuclear option and delete rm -rf ~/.stack/ ... or maybe just try to build pandoc in windows instead of using WSL?Forebode
@Forebode surprisingly the nuclear option does not work either. I've tried windows first there were problems as well, but I'll post a new question for that.Synn
I
3

I had the same problem, also on WSL, and resolved it by upgrading the Ubuntu distro to use WSL2. https://learn.microsoft.com/en-us/windows/wsl/install-win10

Illboding answered 14/2, 2021 at 1:24 Comment(1)
This really fixes the problem, thanks man!Micrometry

© 2022 - 2024 — McMap. All rights reserved.