{"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/41532d114e2ba565fb5367d606c111b29b96450c/src/main.rs#L218-L254","documentation":"Thrown by check_path_separator_length in src/main.rs:236. On Windows only, --path-separator must be exactly one byte; a multi-byte value is rejected because MSYS2/Cygwin/Git-Bash auto-expand a lone '/' into a Windows path, and users often try '//' as a workaround that then arrives as a 2-byte string.","triggerScenarios":"Running 'fd --path-separator \"//\" ...' on Windows; passing any multi-byte or multi-char separator string under cfg(windows).","commonSituations":"Coping with POSIX-path output inside a Git-Bash/MSYS2 pipeline; copy-pasting a separator from a shell that already collapsed '/' to a Windows path.","solutions":["Use a single-byte separator: 'fd --path-separator \"/\" ...' or a single '\\' (note the message's hint about shell expansion).","Quote carefully so the shell does not collapse '/' to a Windows path — in MSYS2 use 'MSYS_NO_PATHCONV=1 fd --path-separator /'.","Omit --path-separator entirely to let fd use the platform default."],"exampleFix":"// before\nfd --path-separator \"//\" .   # on Windows\n\n// after\nMSYS_NO_PATHCONV=1 fd --path-separator / .","handlingStrategy":"validation","validationCode":"# Windows/MSYS: enforce a single-byte separator and disable path conv\nif [ \"${#SEP}\" -ne 1 ]; then\n  echo \"--path-separator must be one byte\" >&2; exit 1\nfi\nMSYS_NO_PATHCONV=1 fd --path-separator \"$SEP\" \"$@\"","typeGuard":"fn is_single_byte_sep(s: &str) -> bool {\n    s.len() == 1\n}","tryCatchPattern":null,"preventionTips":["On Windows pass exactly one byte to --path-separator.","Set MSYS_NO_PATHCONV=1 in Git-Bash/MSYS2 to stop '/' rewriting.","Omit --path-separator unless you specifically need cross-platform output."],"tags":["path-separator","windows","cli-flag","shell-expansion"],"analyzedSha":"41532d114e2ba565fb5367d606c111b29b96450c","analyzedAt":"2026-08-06T01:39:28.509Z","schemaVersion":2}