juicedata/juicefs · error
failed to find command line for pid: %d
Error message
failed to find command line for pid: %d
What it means
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.
Source
Thrown at cmd/debug_windows.go:44
"strconv"
"strings"
"time"
"github.com/juicedata/juicefs/pkg/utils"
"github.com/juicedata/juicefs/pkg/vfs"
"golang.org/x/sys/windows"
)
func getprocessCommandLine(pid int) (string, error) {
cmd := exec.Command("wmic", "process", "where", "ProcessID="+strconv.Itoa(pid), "get", "CommandLine")
out, err := cmd.CombinedOutput()
if err != nil {
return "", fmt.Errorf("failed to run command line: %s, %v", cmd.String(), err)
}
lines := strings.Split(string(out), "\r\n")
if len(lines) < 2 {
return "", fmt.Errorf("failed to find command line for pid: %d", pid)
}
for _, line := range lines[1:] {
sline := strings.TrimSpace(line)
if sline == "" {
continue
}
return sline, nil
}
return "", fmt.Errorf("cannot find command line for pid %d. If the juicefs are mounted at background, Please rerun this with the admin permission.", pid)
}
func findMountProcess(mp string) (int, error) {
processName := filepath.Base(os.Args[0])
cmd := exec.Command("wmic", "process", "where", fmt.Sprintf("name='%s'", processName), "get", "CommandLine,ProcessId")
out, err := cmd.CombinedOutput()
if err != nil {
View on GitHub (pinned to c9a67b23e8)
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
Defensive patterns
Strategy: try-catch
Validate before calling
// Windows / Go: verify the pid is alive and wmic works before calling debug
out, err := exec.Command("tasklist", "/FI", fmt.Sprintf("PID eq %d", pid)).CombinedOutput()
if err != nil || !strings.Contains(string(out), strconv.Itoa(pid)) {
return fmt.Errorf("pid %d is not running; cannot debug", pid)
} Type guard
func processExists(pid int) bool {
h, err := windows.OpenProcess(windows.PROCESS_QUERY_LIMITED_INFORMATION, false, uint32(pid))
if err != nil {
return false
}
windows.CloseHandle(h)
return true
} Try / catch
uid, pid, cmd, err := getCmdMount(mp)
if err != nil {
if strings.Contains(err.Error(), "failed to find command line for pid") {
// stale pid: remount or refresh config, then retry
}
return err
} Prevention
- 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
When it happens
Trigger: `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.
Common situations: 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.
Related errors
- cannot find command line for pid %d. If the juicefs are moun
- failed to exec command line: %s, %s
- failed to find mount process
- failed to parse pid: %s
- failed to run command line: %s, %v
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/cf7a20569e1c932a.
Report an issue: GitHub.