zed-industries/zed · error
failed to create custom data directory
Error message
failed to create custom data directory
What it means
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.
Source
Thrown at crates/paths/src/paths.rs:109
/// directory for all user data, including databases, extensions, and logs.
///
/// # Returns
///
/// A reference to the static `PathBuf` containing the custom data directory path.
///
/// # Panics
///
/// Panics if:
/// * Called after the data directory has been initialized (e.g., via `data_dir` or `config_dir`)
/// * The directory's path cannot be canonicalized to an absolute path
/// * The directory cannot be created
pub fn set_custom_data_dir(dir: &str) -> &'static PathBuf {
if CURRENT_DATA_DIR.get().is_some() || CONFIG_DIR.get().is_some() {
panic!("set_custom_data_dir called after data_dir or config_dir was initialized");
}
CUSTOM_DATA_DIR.get_or_init(|| {
let path = PathBuf::from(dir);
std::fs::create_dir_all(&path).expect("failed to create custom data directory");
let canonicalized = path
.canonicalize()
.expect("failed to canonicalize custom data directory's path to an absolute path");
// On Windows, `canonicalize` produces extended-length paths prefixed
// with `\\?\`. Strip that prefix so downstream consumers (e.g.
// Node.js language servers) that receive derived paths as arguments
// don't choke on the verbatim syntax.
SanitizedPath::new(&canonicalized).as_path().to_path_buf()
})
}
/// Returns the path to the configuration directory used by Zed.
pub fn config_dir() -> &'static PathBuf {
CONFIG_DIR.get_or_init(|| {
if let Some(custom_dir) = CUSTOM_DATA_DIR.get() {
custom_dir.join("config")
} else if cfg!(target_os = "windows") {
dirs::config_dir()View on GitHub (pinned to f4178619ac)
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
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at crates/paths/src/paths.rs:109 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20).
Data as JSON: /api/errors/cfecab5d89a53a02.
Report an issue: GitHub.