Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 884
peer Avatar asked Dec 08 '20 10:12

peer


1 Answers

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

like image 136
Vhon Newmahn Avatar answered Oct 17 '22 22:10

Vhon Newmahn