{"record":{"id":"8585130a3a345a1c","repo":"juicedata/juicefs","slug":"failed-to-run-command-line-s-v","errorCode":null,"errorMessage":"failed to run command line: %s, %v","messagePattern":"failed to run command line: (.+?), (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/debug_windows.go","lineNumber":39,"sourceCode":"\t\"encoding/json\"\r\n\t\"fmt\"\r\n\t\"os\"\r\n\t\"os/exec\"\r\n\t\"path/filepath\"\r\n\t\"strconv\"\r\n\t\"strings\"\r\n\t\"time\"\r\n\r\n\t\"github.com/juicedata/juicefs/pkg/utils\"\r\n\t\"github.com/juicedata/juicefs/pkg/vfs\"\r\n\t\"golang.org/x/sys/windows\"\r\n)\r\n\r\nfunc getprocessCommandLine(pid int) (string, error) {\r\n\tcmd := exec.Command(\"wmic\", \"process\", \"where\", \"ProcessID=\"+strconv.Itoa(pid), \"get\", \"CommandLine\")\r\n\tout, err := cmd.CombinedOutput()\r\n\tif err != nil {\r\n\t\treturn \"\", fmt.Errorf(\"failed to run command line: %s, %v\", cmd.String(), err)\r\n\t}\r\n\r\n\tlines := strings.Split(string(out), \"\\r\\n\")\r\n\tif len(lines) < 2 {\r\n\t\treturn \"\", fmt.Errorf(\"failed to find command line for pid: %d\", pid)\r\n\t}\r\n\r\n\tfor _, line := range lines[1:] {\r\n\t\tsline := strings.TrimSpace(line)\r\n\t\tif sline == \"\" {\r\n\t\t\tcontinue\r\n\t\t}\r\n\t\treturn sline, nil\r\n\t}\r\n\r\n\treturn \"\", fmt.Errorf(\"cannot find command line for pid %d. If the juicefs are mounted at background, Please rerun this with the admin permission.\", pid)\r\n}\r\n\r","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/cmd/debug_windows.go#L21-L57","documentation":"On Windows, `getprocessCommandLine` queries a process's command line via `wmic process where ProcessID=<pid> get CommandLine`. If `wmic` fails to execute or exits non-zero, the full command and error are wrapped with this message; `getCmdMount` then fails and `juicefs debug` reports 'failed to get mount command'.","triggerScenarios":"Running `juicefs debug <mp>` on Windows when `wmic` is absent (removed in Windows 11 newer builds), not on PATH, blocked by policy, or fails for the pid (e.g. the pid exited between enumeration and the wmic query).","commonSituations":"Windows 11 24H2+ where wmic is deprecated/removed; enterprise policy disabling WMIC; debugging a mount process that just exited; running from a shell without the System32 path in PATH.","solutions":["Verify WMIC availability: `wmic /?` in cmd; if removed, install the WMIC feature or use an environment where it exists.","Re-run `juicefs debug` to rule out a pid-exit race.","As a workaround, get the command line via PowerShell: `(Get-CimInstance Win32_Process -Filter \"ProcessId=<pid>\").CommandLine`.","Check PATH includes `C:\\Windows\\System32\\wbem` where wmic resides."],"exampleFix":"// before (wmic removed on Win11 24H2)\nPS> juicefs debug Z:\\\nfailed to run command line: wmic process ... : exec: \"wmic\": executable file not found\n// after (manual check via PowerShell)\nPS> (Get-CimInstance Win32_Process -Filter \"ProcessId=1234\").CommandLine","handlingStrategy":"validation","validationCode":"if _, err := exec.LookPath(\"wmic\"); err != nil {\n  return fmt.Errorf(\"wmic unavailable; use PowerShell Get-CimInstance instead\")\n}","typeGuard":"null","tryCatchPattern":"err := runDebug(mp)\nif err != nil && strings.Contains(err.Error(), \"failed to run command line\") {\n  // wmic missing or pid exited; fall back to Get-CimInstance query and retry\n}","preventionTips":["Check WMIC availability on the target Windows version (deprecated on Win11 24H2+)","Ensure System32\\wbem is in PATH","Re-run promptly to avoid pid-exit races between enumeration and query"],"tags":["windows","process","exec"],"backgroundTag":"command-not-found","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}