zed-industries/zed · error
failed to canonicalize custom data directory's path to an ab
Error message
failed to canonicalize custom data directory's path to an absolute path
What it means
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.
Source
Thrown at crates/paths/src/paths.rs:112
///
/// 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()
.expect("failed to determine RoamingAppData directory")
.join(APP_NAME)
} else if cfg!(any(target_os = "linux", target_os = "freebsd")) {View on GitHub (pinned to f4178619ac)
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
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at crates/paths/src/paths.rs:112 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/c4b94e0a4812fe77.
Report an issue: GitHub.