{"record":{"id":"4352d930eec4472c","repo":"zed-industries/zed","slug":"failed-to-create-directory","errorCode":null,"errorMessage":"Failed to create directory","messagePattern":"Failed to create directory","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/edit_prediction_cli/src/paths.rs","lineNumber":29,"sourceCode":"pub static REPOS_DIR: LazyLock<PathBuf> = LazyLock::new(|| ensure_dir(&DATA_DIR.join(\"repos\")));\npub static WORKTREES_DIR: LazyLock<PathBuf> =\n    LazyLock::new(|| ensure_dir(&DATA_DIR.join(\"worktrees\")));\npub static RUN_DIR: LazyLock<PathBuf> = LazyLock::new(|| {\n    DATA_DIR\n        .join(\"runs\")\n        .join(chrono::Local::now().format(\"%d-%m-%y-%H_%M_%S\").to_string())\n});\npub static LATEST_EXAMPLE_RUN_DIR: LazyLock<PathBuf> = LazyLock::new(|| DATA_DIR.join(\"latest\"));\npub static LATEST_FAILED_EXAMPLES_DIR: LazyLock<PathBuf> =\n    LazyLock::new(|| DATA_DIR.join(\"latest_failed\"));\npub static LLM_CACHE_DB: LazyLock<PathBuf> = LazyLock::new(|| CACHE_DIR.join(\"llm_cache.sqlite\"));\npub static SYNTHESIZE_STATE_FILE: LazyLock<PathBuf> =\n    LazyLock::new(|| DATA_DIR.join(\"synthesize_state.json\"));\npub static FAILED_EXAMPLES_DIR: LazyLock<PathBuf> =\n    LazyLock::new(|| ensure_dir(&RUN_DIR.join(\"failed\")));\n\nfn ensure_dir(path: &Path) -> PathBuf {\n    std::fs::create_dir_all(path).expect(\"Failed to create directory\");\n    path.to_path_buf()\n}\n","sourceCodeStart":11,"sourceCodeEnd":32,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/edit_prediction_cli/src/paths.rs#L11-L32","documentation":"A generic guard inside the ensure_dir helper: it calls create_dir_all on the resolved data directory (repos/, worktrees/, runs/, latest/, ...) and panics if the OS reports an error. The input at fault is the derived directory path under DATA_DIR — it fires for permission denials, a parent that is a file, read-only mounts, or I/O errors, not for the common 'already exists' case which create_dir_all tolerates.","triggerScenarios":"Thrown at crates/edit_prediction_cli/src/paths.rs:29 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Change ensure_dir to return io::Result<PathBuf> and propagate the error instead of panicking inside LazyLock::new","Print an actionable message naming the directory and the underlying io::Error kind before exiting","Check parent directory permissions and disk availability at CLI startup before the LazyLock statics are first touched"],"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-14T00:17:10.932Z"}