Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ every deployment:

### OpenBot Desktop

- **A Windows machine that has only WSL 1 is now told how to convert it.** When the WSL
`DefaultVersion` registry value was absent, setup reported WSL 2 and then tried
`wsl.exe --version`, which the older inbox binary does not understand, so it ended on "could not
check the WSL version" with no next step. An absent value now means WSL 1, and setup shows the
`wsl --set-default-version 2` instructions.
- **Get Troubleshooting Logs… no longer quits OpenBot Desktop on a Mac.** Chosen from the OpenBot
menu, it could seem to do nothing for a few seconds and then close the app, after saving the
file. macOS refused to show the file in Finder from where OpenBot asked. It now asks from the
Expand Down
41 changes: 39 additions & 2 deletions desktop/src-tauri/src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,18 @@ impl Blocker {
}

/// Query the same current-user WSL registry value that upstream uses for the default version.
///
/// Windows treats an absent `DefaultVersion` as WSL 1, not WSL 2. Reporting 2 here skipped the
/// WSL1 screen and sent setup to `wsl.exe --version`, which the legacy inbox binary does not
/// understand.
fn default_wsl_version_probe_command() -> &'static str {
r#"$ErrorActionPreference = 'Stop';
$path = 'Software\Microsoft\Windows\CurrentVersion\Lxss';
$key = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey($path);
if ($null -eq $key) { 2; return }
if ($null -eq $key) { 'unset'; return }
try {
$value = $key.GetValue('DefaultVersion', $null);
if ($null -eq $value) { 2; return }
if ($null -eq $value) { 'unset'; return }
if ($value -isnot [int]) { throw 'DefaultVersion is not a registry DWORD' }
$value
} finally {
Expand All @@ -149,6 +153,8 @@ try {

fn parse_default_wsl_version(operation: &str, output: &str) -> Result<u8, Problem> {
match output.trim() {
// No DefaultVersion value means new distributions default to WSL 1.
"unset" => Ok(1),
"1" => Ok(1),
"2" => Ok(2),
other => Err(detection_failed(
Expand Down Expand Up @@ -1367,6 +1373,37 @@ mod tests {
assert_eq!(result, Ok(None));
}

#[test]
fn an_unset_default_version_is_wsl_one() {
assert_eq!(
parse_default_wsl_version("the default WSL version (registry)", "unset"),
Ok(1)
);
}

#[test]
fn an_unset_default_version_reaches_the_wsl_one_screen() {
let mut probe = 0;
let result = blocker_with(
|program, args| {
assert_probe_call(probe, program, args);
let output = if probe == 4 {
"unset\n"
} else {
PROBE_OUTPUTS[probe]
};
probe += 1;
Ok(probe_output(0, output, ""))
},
|| panic!("WSL1 must be reported before the kernel check"),
);
assert_eq!(result, Ok(Some(Blocker::WslOne)));
assert_eq!(
probe, 5,
"the unsupported wsl.exe --version probe must not run"
);
}

fn probe_with_modern_wsl_service(
outputs: [&str; 6],
service: std::io::Result<std::process::Output>,
Expand Down