{"record":{"id":"ad347b81378ee600","repo":"zed-industries/zed","slug":"failed-to-create-junction-from-to","errorCode":null,"errorMessage":"Failed to create junction from {:?} to {:?}","messagePattern":"Failed to create junction from (.+?) to (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/fs/src/fs.rs","lineNumber":752,"sourceCode":"impl Fs for RealFs {\n    async fn create_dir(&self, path: &Path) -> Result<()> {\n        Ok(smol::fs::create_dir_all(path).await?)\n    }\n\n    async fn create_symlink(&self, path: &Path, target: PathBuf) -> Result<()> {\n        #[cfg(unix)]\n        smol::fs::unix::symlink(target, path).await?;\n\n        #[cfg(windows)]\n        if smol::fs::metadata(&target).await?.is_dir() {\n            let status = new_command(\"cmd\")\n                .args([\"/C\", \"mklink\", \"/J\"])\n                .args([path, target.as_path()])\n                .status()\n                .await?;\n\n            if !status.success() {\n                return Err(anyhow::anyhow!(\n                    \"Failed to create junction from {:?} to {:?}\",\n                    path,\n                    target\n                ));\n            }\n        } else {\n            smol::fs::windows::symlink_file(target, path).await?\n        }\n\n        Ok(())\n    }\n\n    async fn create_file(&self, path: &Path, options: CreateOptions) -> Result<()> {\n        let mut open_options = smol::fs::OpenOptions::new();\n        open_options.write(true).create(true);\n        if options.overwrite {\n            open_options.truncate(true);\n        } else if !options.ignore_if_exists {","sourceCodeStart":734,"sourceCodeEnd":770,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/fs/src/fs.rs#L734-L770","documentation":"On Windows, creating a directory symlink/junction via 'cmd /C mklink /J' from {path} to {target} failed — the child process reported non-success status. mklink requires elevated privileges on some configurations and fails if the target is invalid or the junction path already exists, so create_symlink cannot complete for directory targets on this platform.","triggerScenarios":"Thrown at crates/fs/src/fs.rs:707 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check that the junction path does not already exist and the target directory is valid","Capture mklink's stderr for the real reason (privilege/PATH issues) and surface it","Retry after removing a stale junction, or fall back to copying the directory if junctions are unavailable"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9d272b036335401f339d024ea94968fd51016c40","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}