juicedata/juicefs · error
failed to execute command `%s`: %v
Error message
failed to execute command `%s`: %v
What it means
`juicefs debug`'s `getPprofPort` shells out to `lsof -i -nP | grep LISTEN | grep <pid>` to discover the JuiceFS process's pprof port. When that shell pipeline fails to execute or exits non-zero, the command wraps the failure in this error. Note lsof exits non-zero when it finds nothing, so a process with no listening sockets also produces this error.
Source
Thrown at cmd/debug.go:179
if cfg.Port != nil {
if len(strings.Split(cfg.Port.DebugAgent, ":")) >= 2 {
if port, err := strconv.Atoi(strings.Split(cfg.Port.DebugAgent, ":")[1]); err != nil {
logger.Warnf("failed to parse debug agent port: %v", err)
} else {
return port, nil
}
}
}
var lsofArgs []string
if requireRootPrivileges {
lsofArgs = append(lsofArgs, "sudo")
}
lsofArgs = append(lsofArgs, "/bin/sh", "-c", "lsof -i -nP | grep -v grep | grep LISTEN | grep "+pid)
ret, err := exec.Command(lsofArgs[0], lsofArgs[1:]...).CombinedOutput()
if err != nil {
return 0, fmt.Errorf("failed to execute command `%s`: %v", strings.Join(lsofArgs, " "), err)
}
logger.Debugf("lsof output: \n%s", string(ret))
lines := strings.Split(string(ret), "\n")
if len(lines) == 0 {
return 0, fmt.Errorf("pprof will be collected, but no listen port")
}
var listenPort = -1
for _, line := range lines {
fields := strings.Fields(line)
if len(fields) != 0 {
port, err := func() (port int, err error) {
defer func() {
e := recover()
if e != nil {
err = fmt.Errorf("failed to parse listen port: %v", e)
}
}()View on GitHub (pinned to c9a67b23e8)
Solutions
- Install lsof (`apt-get install lsof` / `yum install lsof`) in the environment where debug runs.
- Run the debug command with sufficient privileges (root, or allow the sudo path) so lsof can inspect the target process.
- Verify manually with `lsof -i -nP | grep LISTEN | grep <pid>`; ensure the debug agent is enabled and the process is alive.
- If the process genuinely has no listening port, collect profiles via an explicitly configured debug-agent address instead.
Example fix
// before (inside container) juicefs debug /mnt/jfs // failed to execute command `/bin/sh -c lsof -i -nP | ...`: exec: "lsof": executable file not found // after apt-get install -y lsof && juicefs debug /mnt/jfs
Defensive patterns
Strategy: fallback
Validate before calling
command -v lsof >/dev/null 2>&1 || { echo "lsof required for juicefs debug"; exit 1; }
lsof -i -nP | grep LISTEN | grep $PID || echo "no listening sockets for $PID" Try / catch
if out, err := debugCmd.CombinedOutput(); err != nil {
if strings.Contains(string(out), "failed to execute command") {
log.Printf("debug unavailable (missing lsof or no permission): %v", err)
return
}
} Prevention
- Ensure lsof is installed in every environment where juicefs debug runs.
- Run debug with root privileges or configure sudo for the target user.
- Confirm the target PID is alive and has listening sockets before debugging.
When it happens
Trigger: Running `juicefs debug <mnt>` where lsof is not installed (exec fails with 'executable file not found'), the user lacks permission to inspect the target process's sockets, or the target PID has no listening sockets so lsof returns exit code 1.
Common situations: Minimal containers/images without the `lsof` package; running `juicefs debug` as non-root against a root-owned mount process without sudo; the process crashed or never opened its debug agent port 6060-6099.
Related errors
- pprof will be collected, but no listen port
- failed to get mount command: %v
- failed to execute command `%s`: %v
- find more than one mount process for %s
- no mount command found for %s
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/832565993c4bb723.
Report an issue: GitHub.