Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nix-shell under Windows WSL is broken #1203

Closed
puffnfresh opened this issue Jan 25, 2017 · 15 comments
Closed

nix-shell under Windows WSL is broken #1203

puffnfresh opened this issue Jan 25, 2017 · 15 comments
Assignees

Comments

@puffnfresh
Copy link
Member

WSL is the Windows Subsystem for Linux. It allows us to run Elf binaries under Windows. It works pretty well for nix-build commands but nix-shell is currently failing.

nix-shell fails because it contains a call to derivationForPath which opens up the SQLite DB. It then calls a nix-store command which fails because it also tries to open the DB. SQLite throws a "disk I/O error" for the call.

  • Can we explicitly close the database?
  • Is there a different workaround?
  • What's missing from WSL to make it operate differently to Linux?
@puffnfresh
Copy link
Member Author

I did an strace and saw a WAL file being created. I looked into WAL and saw that SQLite mentioned it with something about concurrency. I then looked into how Nix used WAL and found the use-sqlite-wal flag. Making an /etc/nix/nix.conf file with:

use-sqlite-wal = false

Was enough to get nix-shell to work.

  • Is the downside of this just that Nix will be a bit slower?
  • If the downside is worth it, should we modify the installer to set this when in Windows WSL?
  • Should this be fixed some other way?

@edolstra
Copy link
Member

Maybe this should be reported as a bug in WSL? SQLite is a pretty widely used piece of software, so I assume we're not the only ones affected by this.

@3noch
Copy link

3noch commented May 9, 2017

Is this fixed now?

@3noch
Copy link

3noch commented May 10, 2017

I have confirmed this is still a problem. I've used SQLite with WAL enabled in native Windows applications and it worked fine. There must be something going on in WSL specifically. But you're right that it is only for performance.

@ThomasMader
Copy link

microsoft/WSL#2395 seems to be the issue for WSL.

@nviets
Copy link

nviets commented Apr 15, 2018

Hi all,
I tried to install Nix 2.0 into WSL Ubuntu and ran into this error. It looks related to the above discussion. Is there any work around? I have already tried enabling long-paths.

nathan@DESKTOP-PC:~$ curl https://nixos.org/nix/install | sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2455  100  2455    0     0    781      0  0:00:03  0:00:03 --:--:--   781
downloading Nix 2.0 binary tarball for x86_64-linux from 'https://nixos.org/releases/nix/nix-2.0/nix-2.0-x86_64-linux.tar.bz2' to '/tmp/nix-binary-tarball-unpack.FQRi8GB3yT'...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 21.0M  100 21.0M    0     0  1519k      0  0:00:14  0:00:14 --:--:-- 1665k
performing a single-user installation of Nix...
copying Nix to /nix/store...............................
initialising Nix database...
replacing old 'nix-2.0'
installing 'nix-2.0'
unpacking channels...
error: executing SQLite statement 'pragma synchronous = normal': disk I/O error (in '/nix/var/nix/db/db.sqlite')
error: program '/nix/store/6p2gambjac7xdkd2a7w1dsxdk1q5cq4d-nix-2.0/bin/nix-env' failed with exit code 1

@ThomasMader
Copy link

Have you tried to disable WAL mode as suggested in #1203 (comment)?

@nviets
Copy link

nviets commented Apr 15, 2018

That did the trick. Thanks @ThomasMader and @TerrorJack!

@nergdron
Copy link

note that this is still broken, and the "use-sqlite-wal = false" workaround no longer works, at least on Win10 with the october 2018 update.

@liberuum
Copy link

try adding this to /etc/nix/nix.conf

use-sqlite-wal = false
sandbox = false

@edolstra
Copy link
Member

I wonder if there is some way that we can detect we're running on WSL and disable WAL mode automatically?

@Baughn
Copy link

Baughn commented May 20, 2019

Note that, as far as I understand, WSL 2 should fix this bug. It replaces the Linux API emulation with an actual Linux kernel.

@freeman42x
Copy link

@pcatana Tried your suggestion, but that did not work for me.

@domenkozar
Copy link
Member

This is fixed in master and 2.3.6

@domenkozar
Copy link
Member

One of Cachix users today reported that they had to revert this change to get WSL2 working. Will see how it goes in the following days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests