{"record":{"id":"75aebac43011389c","repo":"sharkdp/fd","slug":"a-path-separator-must-be-exactly-one-byte-but-the","errorCode":null,"errorMessage":"A path separator must be exactly one byte, but the given separator is {} bytes: '{}'.\nIn some shells on Windows, '/' is automatically expanded. Try to use '//' instead.","messagePattern":"A path separator must be exactly one byte, but the given separator is (.+?) bytes: '(.+?)'\\.\nIn some shells on Windows, '/' is automatically expanded\\. Try to use '//' instead\\.","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/main.rs","lineNumber":236,"sourceCode":"fn build_pattern_regex(pattern: &str, opts: &Opts) -> Result<String> {\n    Ok(if opts.glob && !pattern.is_empty() {\n        let glob = GlobBuilder::new(pattern).literal_separator(true).build()?;\n        glob.regex().to_owned()\n    } else if opts.exact {\n        // Anchor the escaped pattern so the full filename (or path) must match exactly.\n        // Literal. No substring matching.\n        format!(\"^{}$\", regex::escape(pattern))\n    } else if opts.fixed_strings {\n        // Treat pattern as literal string if '--fixed-strings' is used\n        regex::escape(pattern)\n    } else {\n        String::from(pattern)\n    })\n}\n\nfn check_path_separator_length(path_separator: Option<&str>) -> Result<()> {\n    match (cfg!(windows), path_separator) {\n        (true, Some(sep)) if sep.len() > 1 => Err(anyhow!(\n            \"A path separator must be exactly one byte, but \\\n                 the given separator is {} bytes: '{}'.\\n\\\n                 In some shells on Windows, '/' is automatically \\\n                 expanded. Try to use '//' instead.\",\n            sep.len(),\n            sep\n        )),\n        _ => Ok(()),\n    }\n}\n\nfn construct_config(mut opts: Opts, pattern_regexps: &[String]) -> Result<Config> {\n    // The search will be case-sensitive if the command line flag is set or\n    // if any of the patterns has an uppercase character (smart case).\n    let case_sensitive = !opts.ignore_case\n        && (opts.case_sensitive\n            || pattern_regexps\n                .iter()","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/sharkdp/fd/blob/ee20f426ddf338ac7ead5c5f00ea49258005caaf/src/main.rs#L218-L254","documentation":"check_path_separator_length (main.rs:234) validates a user-supplied --path-separator on Windows: it must be exactly one byte. Multi-byte values are rejected because fd builds internal path display using byte-level joins and because some Windows shells (MSYS2/Cygwin/PowerShell) auto-expand a lone '/' into a path, prompting the hint to use '//'. Only enforced on Windows (cfg!(windows)).","triggerScenarios":"On Windows, running `fd --path-separator //` or any multi-character/-byte value. The (true, Some(sep)) arm with sep.len() > 1 fires. Note this is a Windows-only guard; Unix passes the (false, _) arm.","commonSituations":"MSYS2/Git-Bash/PowerShell mangling a single '/' into a Windows root path, leading users to type '//' which then exceeds one byte; passing a Unicode separator character.","solutions":["Use a single-byte separator: `fd --path-separator \\` or omit the flag to use the default.","If your shell expands '/', quote the argument or use the native '\\' separator on Windows.","Avoid the flag entirely if you just want default behavior."],"exampleFix":"# before (Windows, '//')\nfd --path-separator // foo\n\n# after (single byte)\nfd --path-separator \\\\ foo","handlingStrategy":"validation","validationCode":"validate_sep() {\n  local s=\"$1\"\n  # Windows: must be exactly one byte\n  if [ ${#s} -eq 1 ]; then\n    fd --path-separator \"$s\" .\n  else\n    echo \"separator must be one byte\" >&2; exit 1\n  fi\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["On Windows, prefer the native '\\' separator or omit the flag.","Quote shell arguments to prevent '/' auto-expansion in MSYS2/PowerShell.","Avoid Unicode separators; fd expects a single byte."],"tags":["path-separator","windows","cli","shell-expansion"],"backgroundTag":null,"analyzedSha":"ee20f426ddf338ac7ead5c5f00ea49258005caaf","analyzedAt":"2026-08-09T08:21:40.573Z","contentChangedAt":"2026-08-09T08:21:40.573Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}