hLock with cabal run in WSL2


I’ve configured a small Haskell project using cabal. Running nix-shell, then cabal run fails with

Build profile: -w ghc-9.0.2 -O1
In order, the following will be built (use -v for more details):
 - reports- (exe:reports) (first run)
ghc-pkg: {handle: /home/adarcy/code/reports/dist-newstyle/build/x86_64-linux/ghc-9.0.2/reports-}: hLock: invalid argument (Invalid argument)

Any idea ? Thanks !

Here is default.nix

  pkgs = import <nixpkgs> { };
  pkgs.haskellPackages.developPackage {
    root = ./.;
    modifier = drv:
      pkgs.haskell.lib.addBuildTools drv (with pkgs.haskellPackages;
        [ cabal-install

Here’s the cabal configuration

cabal-version:      2.4
name:               reports

author:            adarcy
maintainer:         XXX
extra-source-files: CHANGELOG.md

executable reports
    main-is:          Main.hs
    build-depends:    base
                    , time
                    , text
    hs-source-dirs:   app
    default-language: Haskell2010

I’m using Ubuntu in WSL2: Linux B12725 4.4.0-19041-Microsoft #1237-Microsoft Sat Sep 11 14:32:00 PST 2021 x86_64 x86_64 x86_64 GNU/Linux.

Update: upgrading to WSL2 fixed it, as mentionned on stack overflow : haskell - ghc-pkg: Couldn't open database for modification: hLock: invalid argument - Stack Overflow