juicedata/juicefs · error
failed to execute command `%s`: %v
Error message
failed to execute command `%s`: %v
What it means
On Unix, `getCmdMount` locates the JuiceFS mount process by running `ps -f -p <pid>` or `ps -ef | grep ... mount | grep <mp>` through `/bin/sh`. If `exec.Command(...).CombinedOutput()` returns an error (shell or ps cannot run, or ps exits non-zero), the command and error are wrapped with this message.
Source
Thrown at cmd/debug_unix.go:61
if err := json.Unmarshal(content, &cfg); err != nil {
logger.Warnf("failed to unmarshal config file: %v", err)
}
if cfg.Pid != 0 {
tmpPid = strconv.Itoa(cfg.Pid)
}
return nil
}, 3*time.Second)
var psArgs []string
if tmpPid != "" {
pid = tmpPid
psArgs = []string{"/bin/sh", "-c", fmt.Sprintf("ps -f -p %s", pid)}
} else {
psArgs = []string{"/bin/sh", "-c", fmt.Sprintf("ps -ef | grep -v grep | grep mount | grep %s", mp)}
}
ret, err := exec.Command(psArgs[0], psArgs[1:]...).CombinedOutput()
if err != nil {
return "", "", "", fmt.Errorf("failed to execute command `%s`: %v", strings.Join(psArgs, " "), err)
}
var find bool
var ppid string
lines := strings.Split(string(ret), "\n")
for i := len(lines) - 1; i >= 0; i-- {
line := lines[i]
fields := strings.Fields(line)
if len(fields) <= 7 {
continue
}
cmdFields := fields[7:]
for _, arg := range cmdFields {
if mp == arg {
if find {
newCmd := strings.Join(fields[7:], " ")
newUid, newPid, newPpid := strings.TrimSpace(fields[0]), strings.TrimSpace(fields[1]), strings.TrimSpace(fields[2])
if newPid == ppid {
return uid, pid, cmd, nil
View on GitHub (pinned to c9a67b23e8)
Solutions
- Install the `ps`/procps package in the container or debug from the host.
- Ensure `/bin/sh` exists and is executable.
- Re-run `juicefs debug`; a transient pid-exit race usually resolves on retry.
- Check the wrapped `%v` error: 'executable file not found' means missing ps/sh; exit status 1 from `ps -f -p` means the pid no longer exists.
Example fix
// before (minimal container) $ juicefs debug /jfs failed to execute command `/bin/sh -c ps -ef ...`: exec: "ps": executable file not found // after $ apk add procps && juicefs debug /jfs
Defensive patterns
Strategy: validation
Validate before calling
for _, bin := range []string{"/bin/sh", "ps"} {
if _, err := exec.LookPath(bin); err != nil {
return fmt.Errorf("%s missing; install procps", bin)
}
} Type guard
null
Try / catch
err := runDebug(mp)
if err != nil && strings.Contains(err.Error(), "failed to execute command") {
// 'executable file not found' -> install ps/sh; exit status -> retry (pid race)
} Prevention
- Install procps/ps in minimal containers before debugging
- Ensure /bin/sh exists and is executable
- Retry once if the mount pid may have exited mid-scan
When it happens
Trigger: Running `juicefs debug` on Unix when `/bin/sh` is missing, `ps` is not installed (e.g. minimal containers without procps), or `ps -f -p <pid>` fails because the pid vanished between listing and re-checking.
Common situations: Debugging inside a distroless/alpine container without `ps`; restricted seccomp blocking process exec; race where the mount process exits mid-debug.
Related errors
- failed to execute command `%s`: %v
- failed to get mount command: %v
- find more than one mount process for %s
- no mount command found for %s
- failed to run command line: %s, %v
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/62d7f056482189e8.
Report an issue: GitHub.