{"record":{"id":"957568ed29d25164","repo":"sxyazi/yazi","slug":"failed-to-get-current-working-directory","errorCode":null,"errorMessage":"failed to get current working directory","messagePattern":"failed to get current working directory","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-fs/src/cwd.rs","lineNumber":26,"sourceCode":"\npub static CWD: RoCell<Cwd> = RoCell::new();\n\npub struct Cwd(ArcSwap<UrlBuf>);\n\nimpl Deref for Cwd {\n\ttype Target = ArcSwap<UrlBuf>;\n\n\tfn deref(&self) -> &Self::Target { &self.0 }\n}\n\nimpl Default for Cwd {\n\tfn default() -> Self {\n\t\tlet u = std::env::var_os(\"PWD\")\n\t\t\t.map(PathBuf::from)\n\t\t\t.filter(|p| p.is_absolute())\n\t\t\t.map(clean_url)\n\t\t\t.or_else(|| current_dir().ok().map(UrlBuf::from))\n\t\t\t.expect(\"failed to get current working directory\");\n\n\t\tSelf(ArcSwap::new(Arc::new(u)))\n\t}\n}\n\nimpl Cwd {\n\tpub(crate) fn path(&self) -> PathBuf { self.0.load().as_url().working_path().into_owned() }\n\n\tpub fn set(&self, url: &UrlBuf, callback: fn()) -> bool {\n\t\tif !url.is_absolute() && url.auth().is_local() {\n\t\t\treturn false;\n\t\t} else if self.0.load().as_ref() == url {\n\t\t\treturn false;\n\t\t}\n\n\t\tself.0.store(Arc::new(url.clone()));\n\t\tSelf::sync_cwd(callback);\n","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/sxyazi/yazi/blob/a541adde4e5b082719a0f21a87eb3eab071ece58/yazi-fs/src/cwd.rs#L8-L44","documentation":"Error \"failed to get current working directory\" thrown in sxyazi/yazi.","triggerScenarios":"Thrown at yazi-fs/src/cwd.rs:26 when the library encounters an invalid state.","commonSituations":"Querying the process working directory after it has been deleted or made inaccessible by another process.","solutions":["Start Yazi from a valid working directory; the previous cwd may have been deleted — cd to an existing directory first."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a541adde4e5b082719a0f21a87eb3eab071ece58","analyzedAt":"2026-08-19T05:27:26.468Z","contentChangedAt":"2026-08-19T05:27:26.468Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}