{"record":{"id":"cf7a20569e1c932a","repo":"juicedata/juicefs","slug":"failed-to-find-command-line-for-pid-d","errorCode":null,"errorMessage":"failed to find command line for pid: %d","messagePattern":"failed to find command line for pid: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/debug_windows.go","lineNumber":44,"sourceCode":"\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\nfunc findMountProcess(mp string) (int, error) {\r\n\tprocessName := filepath.Base(os.Args[0])\r\n\tcmd := exec.Command(\"wmic\", \"process\", \"where\", fmt.Sprintf(\"name='%s'\", processName), \"get\", \"CommandLine,ProcessId\")\r\n\tout, err := cmd.CombinedOutput()\r\n\tif err != nil {\r","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/cmd/debug_windows.go#L26-L62","documentation":"getprocessCommandLine queries `wmic process where ProcessID=<pid> get CommandLine` to recover the full command line of the JuiceFS mount process. The wmic output is split on \\r\\n and expected to have a header line plus at least one data line; if the output has fewer than 2 lines, wmic returned nothing usable for that pid (typically the process no longer exists or wmic is unavailable/failed silently), so this error is thrown.","triggerScenarios":"`juicefs debug <mountpoint>` calls getCmdMount, which calls getprocessCommandLine with a pid parsed from the mount's config file; wmic returns empty or header-only output because the pid exited between reading the config and querying, the pid is invalid, or wmic produced no tabular output.","commonSituations":"Running `juicefs debug` against a stale config whose mount process already crashed or was killed; querying a pid owned by another user/session that wmic cannot see; running on a Windows edition where `wmic` is removed (newer Windows 11 builds) so the command output is empty.","solutions":["Re-run `juicefs debug` while the mount is actively running; confirm with Task Manager or `tasklist /FI \"PID eq <pid>\"` that the pid exists","Confirm the mountpoint's .config pid is fresh (the config may be stale; re-check the mount)","If wmic is missing (Windows 11 24H2+), install/restore WMIC (Features on Demand) or upgrade JuiceFS to a version using PowerShell CIM fallback","Run the command from an elevated prompt so wmic can query processes of other sessions"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Windows / Go: verify the pid is alive and wmic works before calling debug\nout, err := exec.Command(\"tasklist\", \"/FI\", fmt.Sprintf(\"PID eq %d\", pid)).CombinedOutput()\nif err != nil || !strings.Contains(string(out), strconv.Itoa(pid)) {\n\treturn fmt.Errorf(\"pid %d is not running; cannot debug\", pid)\n}","typeGuard":"func processExists(pid int) bool {\n\th, err := windows.OpenProcess(windows.PROCESS_QUERY_LIMITED_INFORMATION, false, uint32(pid))\n\tif err != nil {\n\t\treturn false\n\t}\n\twindows.CloseHandle(h)\n\treturn true\n}","tryCatchPattern":"uid, pid, cmd, err := getCmdMount(mp)\nif err != nil {\n\tif strings.Contains(err.Error(), \"failed to find command line for pid\") {\n\t\t// stale pid: remount or refresh config, then retry\n\t}\n\treturn err\n}","preventionTips":["Only run `juicefs debug` while the mount is confirmed running","Check the pid from the mountpoint config against the live process list first","On Windows 11 24H2+, verify wmic is installed or use a JuiceFS build with a PowerShell CIM fallback","Run debug from an elevated prompt to avoid empty wmic rows"],"tags":["windows","wmic","process-introspection"],"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"}