{"id":"f35c2ede3daf4de6","repo":"BurntSushi/ripgrep","slug":"failed-to-get-current-working-directory-err-did","errorCode":null,"errorMessage":"failed to get current working directory: {err}\ndid your CWD get deleted?","messagePattern":"failed to get current working directory: (.+?)\ndid your CWD get deleted\\?","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/core/flags/hiargs.rs","lineNumber":1344,"sourceCode":"}\n\n/// Attempts to discover the current working directory.\n///\n/// This mostly just defers to the standard library, however, such things will\n/// fail if ripgrep is in a directory that no longer exists. We attempt some\n/// fallback mechanisms, such as querying the PWD environment variable, but\n/// otherwise return an error.\nfn current_dir() -> anyhow::Result<PathBuf> {\n    let err = match std::env::current_dir() {\n        Err(err) => err,\n        Ok(cwd) => return Ok(cwd),\n    };\n    if let Some(cwd) = std::env::var_os(\"PWD\") {\n        if !cwd.is_empty() {\n            return Ok(PathBuf::from(cwd));\n        }\n    }\n    anyhow::bail!(\n        \"failed to get current working directory: {err}\\n\\\n         did your CWD get deleted?\",\n    )\n}\n\n/// Retrieves the hostname that should be used wherever a hostname is required.\n///\n/// Currently, this is only used in the hyperlink format.\n///\n/// This works by first running the given binary program (if present and with\n/// no arguments) to get the hostname after trimming leading and trailing\n/// whitespace. If that fails for any reason, then it falls back to getting\n/// the hostname via platform specific means (e.g., `gethostname` on Unix).\n///\n/// The purpose of `bin` is to make it possible for end users to override how\n/// ripgrep determines the hostname.\nfn hostname(bin: Option<&Path>) -> Option<String> {\n    let Some(bin) = bin else { return platform_hostname() };","sourceCodeStart":1326,"sourceCodeEnd":1362,"githubUrl":"https://github.com/BurntSushi/ripgrep/blob/3fce3b5bb0236da2df6d99672afb8a719642eca7/crates/core/flags/hiargs.rs#L1326-L1362","documentation":"Error \"failed to get current working directory: {err}\ndid your CWD get deleted?\" thrown in BurntSushi/ripgrep.","triggerScenarios":"Thrown at crates/core/flags/hiargs.rs:1344 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Change to a valid existing directory before running the command","Recreate the deleted working directory or start a new shell"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"3fce3b5bb0236da2df6d99672afb8a719642eca7","analyzedAt":"2026-08-06T01:39:05.073Z","schemaVersion":2}