From 35f5da530aed4dfdb7273eb4a0f600ddde1a4445 Mon Sep 17 00:00:00 2001 From: Brian McKenna Date: Sat, 21 Dec 2019 07:40:23 +1100 Subject: [PATCH] Disable use-sqlite-wal under WSL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before: $ nix-channel --update unpacking channels... warning: SQLite database '/nix/var/nix/db/db.sqlite' is busy (SQLITE_PROTOCOL) warning: SQLite database '/nix/var/nix/db/db.sqlite' is busy (SQLITE_PROTOCOL) warning: SQLite database '/nix/var/nix/db/db.sqlite' is busy (SQLITE_PROTOCOL) warning: SQLite database '/nix/var/nix/db/db.sqlite' is busy (SQLITE_PROTOCOL) warning: SQLite database '/nix/var/nix/db/db.sqlite' is busy (SQLITE_PROTOCOL) After: $ inst/bin/nix-channel --update unpacking channels... created 1 symlinks in user environment I've seen complaints that "sandbox" caused problems under WSL but I'm having no problems. I think recent changes could have fixed the issue. (cherry picked from commit d25923263e0eb70f37536e2fe5b59237f6fce5cc) Signed-off-by: Domen Kožar --- src/libstore/globals.cc | 9 +++++++++ src/libstore/globals.hh | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc index 11de7a931..58c6bbe06 100644 --- a/src/libstore/globals.cc +++ b/src/libstore/globals.cc @@ -103,6 +103,15 @@ StringSet Settings::getDefaultSystemFeatures() return features; } +bool Settings::isWSL1() +{ + struct utsname utsbuf; + uname(&utsbuf); + // WSL1 uses -Microsoft suffix + // WSL2 uses -microsoft-standard suffix + return hasSuffix(utsbuf.release, "-Microsoft"); +} + const string nixVersion = PACKAGE_VERSION; template<> void BaseSetting::set(const std::string & str) diff --git a/src/libstore/globals.hh b/src/libstore/globals.hh index 7c46cceb4..8bddf086a 100644 --- a/src/libstore/globals.hh +++ b/src/libstore/globals.hh @@ -34,6 +34,8 @@ class Settings : public Config { StringSet getDefaultSystemFeatures(); + bool isWSL1(); + public: Settings(); @@ -130,7 +132,7 @@ public: Setting fsyncMetadata{this, true, "fsync-metadata", "Whether SQLite should use fsync()."}; - Setting useSQLiteWAL{this, true, "use-sqlite-wal", + Setting useSQLiteWAL{this, !isWSL1(), "use-sqlite-wal", "Whether SQLite should use WAL mode."}; Setting syncBeforeRegistering{this, false, "sync-before-registering",