BurntSushi/ripgrep · error
current working directory `{}` is not absolute
Error message
current working directory `{}` is not absolute What it means
Error "current working directory `{}` is not absolute" thrown in BurntSushi/ripgrep.
Source
Thrown at crates/index/src/index.rs:127
}
impl IndexDiscovery {
pub fn new() -> IndexDiscovery {
IndexDiscovery {
builder: IndexBuilder::new(),
cwd: None,
env_name: "RIPGREP_INDEX_PATH".into(),
dir_name: ".ripgrep".into(),
}
}
pub fn discover(&self) -> anyhow::Result<Option<Index>> {
let cwd = match self.cwd.clone() {
Some(cwd) => cwd,
None => std::env::current_dir()
.context("failed to get current working directory")?,
};
anyhow::ensure!(
cwd.is_absolute(),
"current working directory `{}` is not absolute",
cwd.display()
);
if let Some(env_path) = std::env::var_os(&self.env_name) {
if !env_path.is_empty() {
return Ok(Some(self.builder.build(env_path)?));
}
}
for ancestor in cwd.ancestors() {
let path = ancestor.join(&self.dir_name);
// I guess this is subject to TOCTOU problems, but the underlying
// embedded database should handle synchronization problems for us.
if self.builder.create || Index::exists(&path) {
return Ok(Some(self.builder.build(&path)?));
}
}
Ok(None)View on GitHub (pinned to 3fce3b5bb0)
Solutions
- Run the command from an absolute working directory path
- Pass an absolute path instead of relying on a relative CWD
When it happens
Trigger: Thrown at crates/index/src/index.rs:127 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/9a7659a18b18dc00.json.
Report an issue: GitHub.