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
This commit is contained in:
John Tur authored and GitHub committed 2025-10-14 14:24:03 -04:00
1 parent e18c05338f
commit d9456cb908
1 file changed
+33 -1
+33 -1
View File
@@ -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));