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 · 14 comments
Closed

nix-shell under Windows WSL is broken #1203

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

Comments

@puffnfresh
Copy link
Contributor

@puffnfresh puffnfresh 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
Copy link
Contributor Author

@puffnfresh puffnfresh 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
Copy link
Member

@edolstra edolstra 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
Copy link

@3noch 3noch commented May 9, 2017

Is this fixed now?

@3noch
Copy link

@3noch 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

@ThomasMader ThomasMader commented Oct 27, 2017

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

@nviets
Copy link

@nviets 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

@ThomasMader ThomasMader commented Apr 15, 2018

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

@nviets
Copy link

@nviets nviets commented Apr 15, 2018

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

@nergdron
Copy link

@nergdron nergdron 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
Copy link

@pcatana pcatana commented May 20, 2019

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

use-sqlite-wal = false
sandbox = false

@edolstra
Copy link
Member

@edolstra edolstra 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
Copy link

@Baughn 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.

@razvan-flavius-panda
Copy link

@razvan-flavius-panda razvan-flavius-panda commented May 1, 2020

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

@domenkozar
Copy link
Member

@domenkozar domenkozar commented Jul 15, 2020

This is fixed in master and 2.3.6

@domenkozar domenkozar closed this Jul 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet