{"record":{"id":"c4b94e0a4812fe77","repo":"zed-industries/zed","slug":"failed-to-canonicalize-custom-data-directory-s-pat","errorCode":null,"errorMessage":"failed to canonicalize custom data directory's path to an absolute path","messagePattern":"failed to canonicalize custom data directory's path to an absolute path","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/paths/src/paths.rs","lineNumber":112,"sourceCode":"///\n/// A reference to the static `PathBuf` containing the custom data directory path.\n///\n/// # Panics\n///\n/// Panics if:\n/// * Called after the data directory has been initialized (e.g., via `data_dir` or `config_dir`)\n/// * The directory's path cannot be canonicalized to an absolute path\n/// * The directory cannot be created\npub fn set_custom_data_dir(dir: &str) -> &'static PathBuf {\n    if CURRENT_DATA_DIR.get().is_some() || CONFIG_DIR.get().is_some() {\n        panic!(\"set_custom_data_dir called after data_dir or config_dir was initialized\");\n    }\n    CUSTOM_DATA_DIR.get_or_init(|| {\n        let path = PathBuf::from(dir);\n        std::fs::create_dir_all(&path).expect(\"failed to create custom data directory\");\n        let canonicalized = path\n            .canonicalize()\n            .expect(\"failed to canonicalize custom data directory's path to an absolute path\");\n        // On Windows, `canonicalize` produces extended-length paths prefixed\n        // with `\\\\?\\`. Strip that prefix so downstream consumers (e.g.\n        // Node.js language servers) that receive derived paths as arguments\n        // don't choke on the verbatim syntax.\n        SanitizedPath::new(&canonicalized).as_path().to_path_buf()\n    })\n}\n\n/// Returns the path to the configuration directory used by Zed.\npub fn config_dir() -> &'static PathBuf {\n    CONFIG_DIR.get_or_init(|| {\n        if let Some(custom_dir) = CUSTOM_DATA_DIR.get() {\n            custom_dir.join(\"config\")\n        } else if cfg!(target_os = \"windows\") {\n            dirs::config_dir()\n                .expect(\"failed to determine RoamingAppData directory\")\n                .join(APP_NAME)\n        } else if cfg!(any(target_os = \"linux\", target_os = \"freebsd\")) {","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/paths/src/paths.rs#L94-L130","documentation":"Panic in set_custom_data_dir when Path::canonicalize on the user-provided dir fails: the path does not exist, is not accessible, or a component is a dangling symlink. Canonicalization requires the path to resolve on the filesystem, so a typo'd or not-yet-created custom data dir triggers this.","triggerScenarios":"Thrown at crates/paths/src/paths.rs:112 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Create the directory before calling set_custom_data_dir, or create it first then canonicalize","Check for typos, dangling symlinks, and traversal permissions on every component of the path","Return the io::Error instead of unwrapping so callers can surface a clear message"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}