BurntSushi/ripgrep · error
separator must be valid UTF-8 (use escape sequences to provi
Error message
separator must be valid UTF-8 (use escape sequences to provide a separator that is not valid UTF-8)
What it means
Error "separator must be valid UTF-8 (use escape sequences to provide a separator that is not valid UTF-8)" thrown in BurntSushi/ripgrep.
Source
Thrown at crates/core/flags/lowargs.rs:497
/// Represents the separator to use between non-contiguous sections of
/// contextual lines.
///
/// The default is `--`.
#[derive(Clone, Debug, Eq, PartialEq)]
pub(crate) struct ContextSeparator(Option<BString>);
impl Default for ContextSeparator {
fn default() -> ContextSeparator {
ContextSeparator(Some(BString::from("--")))
}
}
impl ContextSeparator {
/// Create a new context separator from the user provided argument. This
/// handles unescaping.
pub(crate) fn new(os: &OsStr) -> anyhow::Result<ContextSeparator> {
let Some(string) = os.to_str() else {
anyhow::bail!(
"separator must be valid UTF-8 (use escape sequences \
to provide a separator that is not valid UTF-8)"
)
};
Ok(ContextSeparator(Some(Vec::unescape_bytes(string).into())))
}
/// Creates a new separator that instructs the printer to disable contextual
/// separators entirely.
pub(crate) fn disabled() -> ContextSeparator {
ContextSeparator(None)
}
/// Return the raw bytes of this separator.
///
/// If context separators were disabled, then this returns `None`.
///
/// Note that this may return a `Some` variant with zero bytes.View on GitHub (pinned to 3fce3b5bb0)
Solutions
- Use a separator that is valid UTF-8
- Provide arbitrary bytes via escape sequences for the separator
When it happens
Trigger: Thrown at crates/core/flags/lowargs.rs:497 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BurntSushi/ripgrep@3fce3b5bb0 (2026-08-06).
Data as JSON: /data/errors/054d0a4709e58703.json.
Report an issue: GitHub.