{"record":{"id":"a07165467a9753d5","repo":"cloudflare/cloudflared","slug":"error-retrieving-output-from-command-s-w-a07165","errorCode":null,"errorMessage":"error retrieving output from command '%s': %w","messagePattern":"error retrieving output from command '(.+?)': %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"diagnostic/system_collector_utils.go","lineNumber":344,"sourceCode":"\tbuilder.WriteString(\"---END Memory information\\n\")\n\tbuilder.WriteString(\"---BEGIN File descriptors information\\n\")\n\tformatInfo(fdInfoRaw, &builder)\n\tbuilder.WriteString(\"---END File descriptors information\\n\")\n\tbuilder.WriteString(\"---BEGIN Disks information\\n\")\n\tformatInfo(disksRaw, &builder)\n\tbuilder.WriteString(\"---END Disks information\\n\")\n\n\trawInformation := builder.String()\n\n\treturn rawInformation\n}\n\nfunc collectDiskVolumeInformationUnix(ctx context.Context) ([]*DiskVolumeInformation, string, error) {\n\tcommand := exec.CommandContext(ctx, \"df\", \"-k\")\n\n\tstdout, err := command.Output()\n\tif err != nil {\n\t\treturn nil, \"\", fmt.Errorf(\"error retrieving output from command '%s': %w\", command.String(), err)\n\t}\n\n\toutput := string(stdout)\n\n\tdisks, err := ParseDiskVolumeInformationOutput(output, 1, 1)\n\tif err != nil {\n\t\treturn nil, output, err\n\t}\n\n\t// returning raw output in case other collected information\n\t// resulted in errors\n\treturn disks, output, nil\n}\n\nfunc collectOSInformationUnix(ctx context.Context) (*OsInfo, string, error) {\n\tcommand := exec.CommandContext(ctx, \"uname\", \"-a\")\n\n\tstdout, err := command.Output()","sourceCodeStart":326,"sourceCodeEnd":362,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/diagnostic/system_collector_utils.go#L326-L362","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before: distroless container image\nFROM gcr.io/distroless/static\n\n// after: image that includes df\nFROM alpine:3.19\nRUN apk add --no-cache coreutils","handlingStrategy":"try-catch","validationCode":"if _, err := exec.LookPath(\"df\"); err != nil {\n    return fmt.Errorf(\"df not available in PATH: %w\", err)\n}","typeGuard":"func canRunDF() bool {\n    return exec.Command(\"df\", \"-k\").Run() == nil || func() bool {\n        _, err := exec.LookPath(\"df\")\n        return err == nil\n    }()\n}","tryCatchPattern":"disks, raw, err := collector.Collect(ctx)\nif err != nil && strings.Contains(err.Error(), \"error retrieving output from command 'df\") {\n    log.Warn().Err(err).Msg(\"disk volume collection failed; check df availability and mounts\")\n    // proceed without disk info or retry with a longer deadline\n}","preventionTips":["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."],"tags":["go","diagnostics","disk","exec","unix"],"backgroundTag":"command-execution-failed","analyzedSha":"2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f","analyzedAt":"2026-09-06T04:14:33.757Z","contentChangedAt":"2026-09-06T04:14:33.757Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}