{"record":{"id":"8dc90709a02bf637","repo":"zed-industries/zed","slug":"user-is-empty-in-wsl-argument","errorCode":null,"errorMessage":"user is empty in wsl argument","messagePattern":"user is empty in wsl argument","errorType":"console","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/main.rs","lineNumber":437,"sourceCode":"            parse_path_with_position(symlink_path.join(\"ec/tory/file.txt\").to_str().unwrap())\n                .unwrap();\n        assert_eq!(result, expected);\n\n        // Relative path\n        let result = with_cwd(temp_tree.path(), || {\n            parse_path_with_position(\"symlink/ec/tory/file.txt\")\n        })\n        .unwrap();\n        assert_eq!(result, expected);\n    }\n}\n\nfn parse_path_in_wsl(source: &str, wsl: &str) -> Result<String> {\n    let mut source = PathWithPosition::parse_str(source);\n\n    let (user, distro_name) = if let Some((user, distro)) = wsl.split_once('@') {\n        if user.is_empty() {\n            anyhow::bail!(\"user is empty in wsl argument\");\n        }\n        (Some(user), distro)\n    } else {\n        (None, wsl)\n    };\n\n    let mut args = vec![\"--distribution\", distro_name];\n    if let Some(user) = user {\n        args.push(\"--user\");\n        args.push(user);\n    }\n\n    let command = [\n        OsStr::new(\"realpath\"),\n        OsStr::new(\"-s\"),\n        source.path.as_ref(),\n    ];\n","sourceCodeStart":419,"sourceCodeEnd":455,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/cli/src/main.rs#L419-L455","documentation":"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`.","triggerScenarios":"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.","commonSituations":"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.","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 '@'."],"exampleFix":"# before: empty user before '@'\nzed --wsl @Ubuntu /home/me/file.rs   # error: user is empty in wsl argument\n\n# after: omit user for default, or name one\nzed --wsl Ubuntu /home/me/file.rs\nzed --wsl me@Ubuntu /home/me/file.rs","handlingStrategy":"validation","validationCode":"// Validate the --wsl argument before use\nfn valid_wsl_arg(wsl: &str) -> bool {\n    match wsl.split_once('@') {\n        Some((user, _)) => !user.is_empty() && !wsl.starts_with('@') && !wsl.ends_with('@'),\n        None => !wsl.is_empty(),\n    }\n}","typeGuard":"fn parse_wsl_target(wsl: &str) -> Option<(Option<&str>, &str)> {\n    match wsl.split_once('@') {\n        Some((\"\", _)) | None if wsl.is_empty() => None,\n        Some((user, distro)) if !user.is_empty() && !distro.is_empty() => Some((Some(user), distro)),\n        Some(_) => None,\n        None => Some((None, wsl)),\n    }\n}","tryCatchPattern":"match parse_path_in_wsl(source, wsl) {\n    Err(err) if err.to_string().contains(\"user is empty\") => {\n        eprintln!(\"usage: --wsl [user@]distro (drop the leading '@' for the default user)\");\n        std::process::exit(2);\n    }\n    result => result?,\n}","preventionTips":["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."],"tags":["cli","wsl","windows","argument-parsing"],"backgroundTag":"invalid-cli-argument","analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}