{"record":{"id":"275b19f7b2dda30e","repo":"juicedata/juicefs","slug":"failed-to-exec-command-line-s-s","errorCode":null,"errorMessage":"failed to exec command line: %s, %s","messagePattern":"failed to exec command line: (.+?), (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/debug_windows.go","lineNumber":63,"sourceCode":"\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\n\t\treturn 0, fmt.Errorf(\"failed to exec command line: %s, %s\", 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 0, fmt.Errorf(\"failed to find mount process\")\r\n\t}\r\n\r\n\tmp = strings.TrimRight(mp, \"\\\\\")\r\n\tfor _, line := range lines[1:] {\r\n\t\tsline := strings.TrimSpace(line)\r\n\r\n\t\tif sline == \"\" {\r\n\t\t\tcontinue\r\n\t\t}\r\n\r\n\t\t// the first part of commandline contains 'xxx/mount.exe\"'\r\n\t\tslines := strings.SplitN(sline, \".exe\\\" \", 2)\r\n\t\tif len(slines) < 2 {\r","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/cmd/debug_windows.go#L45-L81","documentation":"findMountProcess executes `wmic process where name='<juicefs.exe>' get CommandLine,ProcessId` to enumerate candidate mount processes. If exec.CombinedOutput returns a non-nil error (wmic not found, failed to launch, or exited non-zero), the error is wrapped with the full command string.","triggerScenarios":"`juicefs debug <mountpoint>` with no pid available in the mount config calls findMountProcess; the wmic executable cannot be started (not installed / not on PATH, e.g. Windows 11 24H2+ where WMIC is deprecated) or the WMI service is broken and the query exits non-zero.","commonSituations":"Running on Windows 11 24H2 or Server editions where WMIC was removed; WMI repository corruption; PATH or system32 issues; running inside a restricted container/sandbox without WMI access.","solutions":["Install WMIC via Windows Features on Demand: `DISM /Online /Add-Capability /CapabilityName:WMIC~~~~` or re-enable it in Optional Features","Verify WMI works: run the wmic query manually; if WMI is corrupt, rebuild the repository (`winmgmt /resetrepository`)","Upgrade JuiceFS to a release that uses PowerShell `Get-CimInstance` instead of wmic","Ensure system32 is on PATH and the shell can execute wmic.exe"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// check wmic availability before invoking debug paths that rely on it\nif _, err := exec.LookPath(\"wmic\"); err != nil {\n\treturn fmt.Errorf(\"wmic not available; install WMIC or use a newer JuiceFS build\")\n}","typeGuard":null,"tryCatchPattern":"_, pid, _, err := getCmdMount(mp)\nif err != nil {\n\tif strings.Contains(err.Error(), \"failed to exec command line\") {\n\t\t// wmic missing/broken: prompt install or fall back to config-file pid\n\t}\n\treturn err\n}","preventionTips":["Pre-release checks: ensure wmic.exe exists on target Windows images (deprecated in Windows 11 24H2+)","Keep WMI healthy; avoid disabling the Windows Management Instrumentation service","Pin the pid via the mount config (readConfig) so findMountProcess/wmic is not needed","Upgrade to JuiceFS builds that use PowerShell Get-CimInstance instead of wmic"],"tags":["windows","wmic","exec","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-14T00:17:10.932Z"}