From brenton @end|ng |rom w|ern|k@org  Tue Apr 13 15:15:50 2021
From: brenton @end|ng |rom w|ern|k@org (Brenton Wiernik)
Date: Tue, 13 Apr 2021 09:15:50 -0400
Subject: [Rd] Sys.timezone() fails on Linux under Microsoft WSL
Message-ID: <0LuO6D-1leFVX1GJL-011mQG@mrelay.perfora.net>

In Microsoft?s Windows Subsystem for Linux (WSL or WSL2), there is not system framework, so utilities that depend on it fail. This includes timedatectl which R uses in Sys.timezone(). The timedatectl utility is present on Linux systems installed under WSL/WSL2, but is non-functional. So, when Sys.timezone() checks for Sys.which("timedatectl"), it receives a false positive. The subsequent methods after this if () do work, however.

This can be fixed if line 42 of Sys.timezone() were changed from:
if (nzchar(Sys.which("timedatectl"))) {

to:
if (nzchar(Sys.which("timedatectl")) && !grepl("microsoft", system("uname -r", intern = TRUE), ignore.case = TRUE)) {

"uname -r" returns for example:
"5.4.72-microsoft-standard-WSL2"

So checking for "microsoft" or "WSL" would probably work.


Brenton Wiernik



	[[alternative HTML version deleted]]



[Rd] Sys.timezone() fails on Linux under Microsoft WSL
Brenton Wiernik