{"record":{"id":"cfecab5d89a53a02","repo":"zed-industries/zed","slug":"failed-to-create-custom-data-directory","errorCode":null,"errorMessage":"failed to create custom data directory","messagePattern":"failed to create custom data directory","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/paths/src/paths.rs","lineNumber":109,"sourceCode":"///   directory for all user data, including databases, extensions, and logs.\n///\n/// # Returns\n///\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()","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/paths/src/paths.rs#L91-L127","documentation":"Panic in set_custom_data_dir: creating the user-supplied custom data directory (after canonicalization) failed, e.g., the path is on an unwritable/unavailable filesystem, a non-directory component exists, or permissions deny creation. The function documents this as a hard error because all later paths derive from this root.","triggerScenarios":"Thrown at crates/paths/src/paths.rs:109 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the error source (permissions vs ENOSPC vs ENOTDIR) and fix the target path","Ensure the parent directory exists and is writable before calling set_custom_data_dir","Return a Result from set_custom_data_dir so callers can report the failure instead of aborting startup"],"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"}