go os_error ai_generated true

exec: "ffmpeg": executable file not found in $PATH

ID: go/os-exec-not-found

Also available as: JSON · Markdown
90%Fix Rate
92%Confidence
50Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1 active

Root Cause

os/exec.Command or exec.LookPath cannot find the specified binary in the system PATH. The executable is either not installed or not in a directory listed in $PATH.

generic

Workarounds

  1. 92% success Install the missing binary and ensure it is in PATH
    apt-get install <package>  # or brew install / yum install
    which <binary>  # verify it's in PATH

    Sources: https://pkg.go.dev/os/exec#LookPath

  2. 88% success Use exec.LookPath to check availability before exec.Command
    path, err := exec.LookPath("ffmpeg")
    if err != nil {
        return fmt.Errorf("ffmpeg not installed: %w", err)
    }
    cmd := exec.Command(path, args...)

    Sources: https://pkg.go.dev/os/exec#LookPath

Dead Ends

Common approaches that don't work:

  1. Hardcode an absolute path to the binary 65% fail

    Absolute paths break portability across systems where the binary is installed in different locations (e.g., /usr/bin vs /usr/local/bin vs /snap/bin)

Error Chain

Leads to:
Preceded by:
Frequently confused with: