zed-industries/zed · error · anyhow::Error
user is empty in wsl argument
Error message
user is empty in wsl argument
What it means
The Zed CLI on Windows can resolve paths inside a WSL distribution via `--wsl [user@]distro`. It splits the argument on the first '@': text before is the WSL user, text after the distribution name. A leading '@' means the user part is the empty string — an invalid `wsl --user` value — so parsing bails before invoking `wsl.exe`.
Solutions
- Drop the '@': `zed --wsl Ubuntu` uses the distro's default user.
- Or supply a real user: `zed --wsl myuser@Ubuntu`.
- Check shell quoting/history expansion did not eat the username before the '@'.
Example fix
# before: empty user before '@' zed --wsl @Ubuntu /home/me/file.rs # error: user is empty in wsl argument # after: omit user for default, or name one zed --wsl Ubuntu /home/me/file.rs zed --wsl me@Ubuntu /home/me/file.rs
Defensive patterns
Strategy: validation
Validate before calling
// Validate the --wsl argument before use
fn valid_wsl_arg(wsl: &str) -> bool {
match wsl.split_once('@') {
Some((user, _)) => !user.is_empty() && !wsl.starts_with('@') && !wsl.ends_with('@'),
None => !wsl.is_empty(),
}
} Type guard
fn parse_wsl_target(wsl: &str) -> Option<(Option<&str>, &str)> {
match wsl.split_once('@') {
Some(("", _)) | None if wsl.is_empty() => None,
Some((user, distro)) if !user.is_empty() && !distro.is_empty() => Some((Some(user), distro)),
Some(_) => None,
None => Some((None, wsl)),
}
} Try / catch
match parse_path_in_wsl(source, wsl) {
Err(err) if err.to_string().contains("user is empty") => {
eprintln!("usage: --wsl [user@]distro (drop the leading '@' for the default user)");
std::process::exit(2);
}
result => result?,
} Prevention
- Remember the format is `[user@]distro`; a lone distro means default user.
- Quote the whole `user@distro` argument so shells don't mangle it.
- Fail fast on empty user/distro segments when parsing CLI args.
When it happens
Trigger: Running `zed --wsl @Ubuntu` (or any value starting with '@'): `wsl.split_once('@')` yields an empty user and non-empty distro, tripping the guard. Passing `@` alone behaves the same.
Common situations: Users intending 'default user in distro' and writing `@Ubuntu` thinking the '@' is required syntax; copy-paste from docs where `user@` was optional and got dropped; shell quoting that swallows the username.
Understand the failure class
Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.
Related errors
- run request is missing a 'benchmark' block
- invalid split point kind
- too many arguments
- Autoupdate failed, nothing to rollback
- Autoupdate failed, rollback successful
AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20).
Data as JSON: /api/errors/8dc90709a02bf637.
Report an issue: GitHub.
Appendix: source
Thrown at crates/cli/src/main.rs:437
parse_path_with_position(symlink_path.join("ec/tory/file.txt").to_str().unwrap())
.unwrap();
assert_eq!(result, expected);
// Relative path
let result = with_cwd(temp_tree.path(), || {
parse_path_with_position("symlink/ec/tory/file.txt")
})
.unwrap();
assert_eq!(result, expected);
}
}
fn parse_path_in_wsl(source: &str, wsl: &str) -> Result<String> {
let mut source = PathWithPosition::parse_str(source);
let (user, distro_name) = if let Some((user, distro)) = wsl.split_once('@') {
if user.is_empty() {
anyhow::bail!("user is empty in wsl argument");
}
(Some(user), distro)
} else {
(None, wsl)
};
let mut args = vec!["--distribution", distro_name];
if let Some(user) = user {
args.push("--user");
args.push(user);
}
let command = [
OsStr::new("realpath"),
OsStr::new("-s"),
source.path.as_ref(),
];
View on GitHub (pinned to f4178619ac)