fdLock invalid argument error on WSL Ubuntu Bionic
ygale opened this issue · 13 comments
Describe the bug
On Ubuntu Bionic running under WSL on Windows 10, after installing cabal-install-3.2 from the hvr PPA:
Every cabal command fails with the following error:
fdLock: invalid argument (Invalid argument)
To Reproduce
Run cabal init, or cabal update or any other cabal command except cabal --version.
I deleted the entire ~/.cabal directory and ran cabal update. Same issue.
System information
- Operating system: Ubuntu 18.04 (bionic), on WSL 1, on Windows 10
cabalversions:
cabal-install version 3.2.0.0
compiled using version 3.2.0.0 of the Cabal libraryghcversion: 8.8.2
Looks like cabal is trying to use fcntl(F_SETLK) or similar for locking, via the lukko library. That won't work on WSL 1, see microsoft/WSL#1927.
It seems clear that Microsoft will not fix this. They are focusing on WSL 2, which won't be generally released for at least a few more months.
Is there any way to teach cabal not to use that kind of locking on this platform? Perhaps a flag that lets you override autodetection of what kind of locking to use?
Closing this. Turning off ofd-locking might or might not work, but there's nothing to do in Cabal or lukko.
To confirm that @phadej's fix works: I added
constraints:
lukko -ofd-lockingto cabal-install's cabal.project file when building cabal-install. This solved the issue, which I was running into on an Alpine Linux WSL2 distribution.
For what it's worth: I had exactly this issue on my WSL 1 system, while building almost any project with Cabal. I just upgraded today to Windows 2004 and WSL 2, and now it seems to work.
In case anybody else wonders if WSL 2 does solve this problem 😄
I met the same problem and have no solution yet:(
I met the same problem and have no solution yet:(
It works after I updated wsl1 to wsl2 :)
For what it's worth: I had exactly this issue on my WSL 1 system, while building almost any project with Cabal. I just upgraded today to Windows 2004 and WSL 2, and now it seems to work.
Thank you, this seems to fix the issue for me. I was running Ubuntu-18.04 on WSL 1. To upgrade it I first got the name of the image:
wsl -l -vwhich showed me Ubuntu-18.04 Running 2 and then i ran
wsl --set-version Ubuntu-18.04 2That took some time, but after that I restarted the Ubuntu shell and everything worked fine. Thank you for the solution, that saved me some time 👍
@leftaroundabout: How to reproduce your findings?
Fresh Debian i386 install, fresh GHC-8.6.5, Cabal HEAD version (5b4258), after running the bootstrap.py following the instructions the resulting cabal executable has the fdLock invalid argument problem discussed here. Nuking the cabal clone, re-cloning, adding the lukko constraints in cabal.project.bootstrap and again bootstrapping did not make any difference.
Ok, I think I got it: the cabal.project.bootstrap isn't actually what matters to the bootstrap (?) and the flag instead needs to be set in bootstrap/linux-8.6.5.json. After changing
...
"package": "lukko"
...
"flags": [
"+ofd-locking"
]
to
"flags": [
"-ofd-locking"
]
in the JSON file, the fdLock issue is gone.
Congratulations! Indeed bootstrap/README.md confirms this project file is used to create bootstrap data for new architectures and that's how it's used in the Makefile.