cloudflare/cloudflared · error
error retrieving output from command '%s': %w
Error message
error retrieving output from command '%s': %w
What it means
collectDiskVolumeInformationUnix runs 'df -k' via exec.CommandContext and this error wraps any failure of command.Output() — meaning df could not be executed or exited non-zero. The command's string form and the underlying exec error are wrapped so you can see both which command failed and why (not-found, exit status, signal). It is raised before any parsing happens, so it always indicates an execution/environment problem, not a data-format problem.
Source
Thrown at diagnostic/system_collector_utils.go:344
builder.WriteString("---END Memory information\n")
builder.WriteString("---BEGIN File descriptors information\n")
formatInfo(fdInfoRaw, &builder)
builder.WriteString("---END File descriptors information\n")
builder.WriteString("---BEGIN Disks information\n")
formatInfo(disksRaw, &builder)
builder.WriteString("---END Disks information\n")
rawInformation := builder.String()
return rawInformation
}
func collectDiskVolumeInformationUnix(ctx context.Context) ([]*DiskVolumeInformation, string, error) {
command := exec.CommandContext(ctx, "df", "-k")
stdout, err := command.Output()
if err != nil {
return nil, "", fmt.Errorf("error retrieving output from command '%s': %w", command.String(), err)
}
output := string(stdout)
disks, err := ParseDiskVolumeInformationOutput(output, 1, 1)
if err != nil {
return nil, output, err
}
// returning raw output in case other collected information
// resulted in errors
return disks, output, nil
}
func collectOSInformationUnix(ctx context.Context) (*OsInfo, string, error) {
command := exec.CommandContext(ctx, "uname", "-a")
stdout, err := command.Output()View on GitHub (pinned to 2253eeeb25)
Solutions
- Check the wrapped error: 'exec: "df": executable file not found in $PATH' means install/restore df (e.g. apt-get install coreutils / use a fuller base image).
- Run 'df -k' manually as the same user to see the non-zero exit reason; fix the offending mount (e.g. unmount stale NFS entries with 'umount -l').
- Verify PATH includes /bin and /usr/bin for the process user (containers and systemd units often have trimmed PATH).
- If the error is 'context deadline exceeded' or 'signal: killed', increase the diagnostic timeout or resolve the slow mount causing df to hang.
- Confirm no MAC policy (SELinux/AppArmor) blocks executing df for the cloudflared process.
Example fix
// before: distroless container image FROM gcr.io/distroless/static // after: image that includes df FROM alpine:3.19 RUN apk add --no-cache coreutils
Defensive patterns
Strategy: try-catch
Validate before calling
if _, err := exec.LookPath("df"); err != nil {
return fmt.Errorf("df not available in PATH: %w", err)
} Type guard
func canRunDF() bool {
return exec.Command("df", "-k").Run() == nil || func() bool {
_, err := exec.LookPath("df")
return err == nil
}()
} Try / catch
disks, raw, err := collector.Collect(ctx)
if err != nil && strings.Contains(err.Error(), "error retrieving output from command 'df") {
log.Warn().Err(err).Msg("disk volume collection failed; check df availability and mounts")
// proceed without disk info or retry with a longer deadline
} Prevention
- Use container base images that include coreutils/df; avoid scratch and distroless for anything running diagnostics.
- Keep /bin and /usr/bin on PATH for service accounts and containers.
- Unmount stale network mounts (NFS/CIFS) before running diagnostics; use 'df -k -x nfs' style checks if hangs recur.
- Set a generous but bounded context deadline so a hanging df surfaces as a timeout, not a deadlock.
When it happens
Trigger: Collect() invokes collectDiskVolumeInformationUnix on a Unix system; 'df' is not in PATH, is not executable, the context is cancelled before completion, or df exits non-zero (e.g. a stale NFS mount hang or permission problem on a mounted filesystem).
Common situations: Minimal Docker images without coreutils' df (distroless/scratch images), restricted PATH in systemd services or containers, hung network mounts making df block until the request context times out, or SELinux/AppArmor policies denying exec.
Related errors
- expected disk volume to have %d fields got %d: %w
- error getting stderr pipe: %v
- error starting %s: %v
- %s %v returned with error code %v due to: %v
- error opening file %s:%w
AI-assisted analysis of cloudflare/cloudflared@2253eeeb25 (2026-09-06).
Data as JSON: /api/errors/a07165467a9753d5.
Report an issue: GitHub.