{"id":"9a7659a18b18dc00","repo":"BurntSushi/ripgrep","slug":"current-working-directory-is-not-absolute","errorCode":null,"errorMessage":"current working directory `{}` is not absolute","messagePattern":"current working directory `(.+?)` is not absolute","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/index/src/index.rs","lineNumber":127,"sourceCode":"}\n\nimpl IndexDiscovery {\n    pub fn new() -> IndexDiscovery {\n        IndexDiscovery {\n            builder: IndexBuilder::new(),\n            cwd: None,\n            env_name: \"RIPGREP_INDEX_PATH\".into(),\n            dir_name: \".ripgrep\".into(),\n        }\n    }\n\n    pub fn discover(&self) -> anyhow::Result<Option<Index>> {\n        let cwd = match self.cwd.clone() {\n            Some(cwd) => cwd,\n            None => std::env::current_dir()\n                .context(\"failed to get current working directory\")?,\n        };\n        anyhow::ensure!(\n            cwd.is_absolute(),\n            \"current working directory `{}` is not absolute\",\n            cwd.display()\n        );\n        if let Some(env_path) = std::env::var_os(&self.env_name) {\n            if !env_path.is_empty() {\n                return Ok(Some(self.builder.build(env_path)?));\n            }\n        }\n        for ancestor in cwd.ancestors() {\n            let path = ancestor.join(&self.dir_name);\n            // I guess this is subject to TOCTOU problems, but the underlying\n            // embedded database should handle synchronization problems for us.\n            if self.builder.create || Index::exists(&path) {\n                return Ok(Some(self.builder.build(&path)?));\n            }\n        }\n        Ok(None)","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/BurntSushi/ripgrep/blob/3fce3b5bb0236da2df6d99672afb8a719642eca7/crates/index/src/index.rs#L109-L145","documentation":"Error \"current working directory `{}` is not absolute\" thrown in BurntSushi/ripgrep.","triggerScenarios":"Thrown at crates/index/src/index.rs:127 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Run the command from an absolute working directory path","Pass an absolute path instead of relying on a relative CWD"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"3fce3b5bb0236da2df6d99672afb8a719642eca7","analyzedAt":"2026-08-06T01:39:05.073Z","schemaVersion":2}