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

Open
puffnfresh opened this issue Jan 25, 2017 · 12 comments

Comments

Projects
None yet
10 participants
@puffnfresh
Copy link
Contributor

commented Jan 25, 2017

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

This comment has been minimized.

Copy link
Contributor Author

commented Jan 25, 2017

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

This comment has been minimized.

Copy link
Member

commented Jan 25, 2017

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

This comment has been minimized.

Copy link

commented May 9, 2017

Is this fixed now?

@3noch

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Oct 27, 2017

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

@nviets

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Apr 15, 2018

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

@nviets

This comment has been minimized.

Copy link

commented Apr 15, 2018

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

@nergdron

This comment has been minimized.

Copy link

commented Mar 12, 2019

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.

@pcatana

This comment has been minimized.

Copy link

commented May 20, 2019

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

use-sqlite-wal = false
sandbox = false
@edolstra

This comment has been minimized.

Copy link
Member

commented May 20, 2019

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

@Baughn

This comment has been minimized.

Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.