From 750c0b3e654a91e243395053e82884b7c69e7b5f Mon Sep 17 00:00:00 2001 From: John Tur Date: Tue, 14 Oct 2025 14:24:03 -0400 Subject: [PATCH] Don't probe for local workspaces pointing to WSL filesystem on startup (#40142) We automatically delete a local workspace if the folders comprising it no longer exist. If a local workspace points to folders in the WSL filesystem, checking whether those folders exist will make us wait for the WSL VM and file server to boot up. This can block Zed startup for many seconds. Supported scenarios use remote workspaces, so delete these local workspaces to ensure that we don't try to access their folders on the startup path. Release Notes: - N/A --- crates/workspace/src/persistence.rs | 34 ++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/crates/workspace/src/persistence.rs b/crates/workspace/src/persistence.rs index efd5116dc39d3ca615112c503ea135b7da076264..f8a0633d93674d153ae675d2125f06caa3bc93cb 100644 --- a/crates/workspace/src/persistence.rs +++ b/crates/workspace/src/persistence.rs @@ -1347,7 +1347,39 @@ impl WorkspaceDb { continue; } - if paths.paths().iter().all(|path| path.exists()) + let has_wsl_path = if cfg!(windows) { + fn is_wsl_path(path: &PathBuf) -> bool { + use std::path::{Component, Prefix}; + + path.components() + .next() + .and_then(|component| match component { + Component::Prefix(prefix) => Some(prefix), + _ => None, + }) + .and_then(|prefix| match prefix.kind() { + Prefix::UNC(server, _) => Some(server), + Prefix::VerbatimUNC(server, _) => Some(server), + _ => None, + }) + .map(|server| { + let server_str = server.to_string_lossy(); + server_str == "wsl.localhost" || server_str == "wsl$" + }) + .unwrap_or(false) + } + + paths.paths().iter().any(|path| is_wsl_path(path)) + } else { + false + }; + + // Delete the workspace if any of the paths are WSL paths. + // If a local workspace points to WSL, this check will cause us to wait for the + // WSL VM and file server to boot up. This can block for many seconds. + // Supported scenarios use remote workspaces. + if !has_wsl_path + && paths.paths().iter().all(|path| path.exists()) && paths.paths().iter().any(|path| path.is_dir()) { result.push((id, SerializedWorkspaceLocation::Local, paths));