{"record":{"id":"a6c7dade5046e443","repo":"jdx/mise","slug":"cmd-exe-cannot-use-a-unc-path-as-a-working-directo-a6c7da","errorCode":null,"errorMessage":"cmd.exe cannot use a UNC path as a working directory\n\n  working directory: {dir}\n\nIt would start in C:\\Windows instead and run the command there, so mise stops rather\nthan running it somewhere you did not ask for.","messagePattern":"cmd\\.exe cannot use a UNC path as a working directory\n\n  working directory: (.+?)\n\nIt would start in C:\\\\Windows instead and run the command there, so mise stops rather\nthan running it somewhere you did not ask for\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/task/task_executor.rs","lineNumber":1438,"sourceCode":"        let mut inputs = Vec::with_capacity(cache.command_inputs.len());\n        for command in &cache.command_inputs {\n            if command.trim().is_empty() {\n                eyre::bail!(\n                    \"task {} cache command input must not be empty: {command:?}\",\n                    task.name\n                );\n            }\n            let (program, args, cmd_verbatim) =\n                self.get_cmd_program_and_args(command, task, &[])?;\n            // The same refusal as in `exec_program`, and it matters more here: these commands feed\n            // the cache key, so running them from C:\\Windows would hash the wrong directory's\n            // answer. Measured on 2026.8.6 with the project on a UNC share — a `command_inputs`\n            // entry reading a file that exists in the project fails, while the same config on a\n            // local path succeeds. `--dry-run` does not reach here (see the cache branch in\n            // `run_task`), so there is nothing to exempt.\n            #[cfg(windows)]\n            if cmd_shell_cannot_use_dir(&program, &root) {\n                eyre::bail!(\"{}\", unc_working_dir_error(&root));\n            }\n            #[cfg(not(windows))]\n            let _ = cmd_verbatim;\n            let program = program.to_executable();\n            #[cfg(windows)]\n            let program = crate::path::resolve_posix_shell_program_path(&program, &filtered_env)\n                .unwrap_or(program);\n            let runner = CmdLineRunner::new(program);\n            #[cfg(windows)]\n            let runner = if cmd_verbatim {\n                args.iter().fold(runner, |runner, arg| runner.raw_arg(arg))\n            } else {\n                runner.args(&args)\n            };\n            #[cfg(not(windows))]\n            let runner = runner.args(&args);\n            let mut runner = runner\n                .current_dir(&root)","sourceCodeStart":1420,"sourceCodeEnd":1456,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/task/task_executor.rs#L1420-L1456","documentation":"On Windows, when a task's cache command runs under cmd.exe, the working directory must be a real drive path: cmd.exe cannot start in a UNC path (\\\\server\\share\\...) and would instead start in C:\\Windows, silently running the command elsewhere. mise detects this (cmd_shell_cannot_use_dir) and stops with this error instead of executing the command in an unexpected directory.","triggerScenarios":"Running a task on Windows whose project/working root is a UNC path (\\\\server\\share\\proj or \\\\wsl$\\...) while the cache command_input's program resolves to cmd.exe/cmd/%COMSPEC% — hit in the cache command-input path at task_executor.rs:1437.","commonSituations":"Source checked out on a network share; corporate environments without mapped drives; \\\\wsl$ interop paths; CI workspace on a UNC share with cmd as the shell.","solutions":["Map the UNC share to a drive letter (net use Z: \\\\server\\share) and run the project from Z:\\...","Move/copy the project to a local drive (e.g. C:\\src\\proj)","Change the task command so it doesn't run under cmd.exe (use pwsh, which supports UNC cwd) on Windows","Use `subst` to alias a drive letter to the UNC path as a quick fix"],"exampleFix":"# before (cwd on UNC share, cmd.exe)\ncd \\\\server\\share\\proj && mise run build\n# after\nnet use Z: \\\\server\\share\ncd Z:\\proj && mise run build","handlingStrategy":"validation","validationCode":"import os\nif os.name == \"nt\" and cwd.startswith(\"\\\\\\\\\"):\n    raise SystemExit(\"cmd.exe tasks need a drive-letter cwd; map the UNC share first\")","typeGuard":"fn cmd_compatible_cwd(dir: &std::path::Path) -> bool {\n    !cfg!(windows) || dir.to_str().map(|s| !s.starts_with(\"\\\\\\\\\")).unwrap_or(true)\n}","tryCatchPattern":"try {\n  execSync(\"mise run build\", { cwd: projectDir });\n} catch (e) {\n  if (String(e).includes(\"UNC path as a working directory\")) {\n    console.error(\"Map the share to a drive letter, e.g. net use Z: \\\\\\\\server\\\\share\");\n  }\n  throw e;\n}","preventionTips":["Keep development projects on local drives on Windows","Map network shares to drive letters before running tasks","Prefer pwsh over cmd.exe for tasks in UNC-hosted repos","Avoid \\\\wsl$ paths as Windows working directories"],"tags":["windows","cmd","unc-path","task"],"backgroundTag":"unsupported-platform","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}