{"record":{"id":"6a2c6d20fcd58e41","repo":"nektos/act","slug":"cannot-find-cmd-in-path","errorCode":null,"errorMessage":"Cannot find: {cmd} in PATH","messagePattern":"Cannot find: (.+?) in PATH","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/container/host_environment.go","lineNumber":228,"sourceCode":"\tif runtime.GOOS == \"windows\" {\n\t\tfor k, v := range l.env {\n\t\t\tif strings.EqualFold(name, k) {\n\t\t\t\treturn v\n\t\t\t}\n\t\t}\n\t\treturn \"\"\n\t}\n\treturn l.env[name]\n}\n\nfunc lookupPathHost(cmd string, env map[string]string, writer io.Writer) (string, error) {\n\tf, err := lookpath.LookPath2(cmd, &localEnv{env: env})\n\tif err != nil {\n\t\terr := \"Cannot find: \" + fmt.Sprint(cmd) + \" in PATH\"\n\t\tif _, _err := writer.Write([]byte(err + \"\\n\")); _err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"%v: %w\", err, _err)\n\t\t}\n\t\treturn \"\", errors.New(err)\n\t}\n\treturn f, nil\n}\n\nfunc setupPty(cmd *exec.Cmd, cmdline string) (*os.File, *os.File, error) {\n\tppty, tty, err := openPty()\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tif term.IsTerminal(int(tty.Fd())) {\n\t\t_, err := term.MakeRaw(int(tty.Fd()))\n\t\tif err != nil {\n\t\t\tppty.Close()\n\t\t\ttty.Close()\n\t\t\treturn nil, nil, err\n\t\t}\n\t}\n\tcmd.Stdin = tty","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/nektos/act/blob/4f411281417e88660bea1c1a1749aa71ae0bd60f/pkg/container/host_environment.go#L210-L246","documentation":"lookupPathHost resolves a executable name using lookpath.LookPath2 against the job's effective environment (PATH included). If the command is not found in any PATH directory, it writes 'Cannot find: <cmd> in PATH' to the step's output writer and returns it as an error. This is the host-execution (-self-hosted/--bind) equivalent of 'command not found', with the job's env applied rather than your interactive shell's.","triggerScenarios":"A run step executing a tool absent from the PATH act passes to host execution: e.g. 'run: terraform plan' with no terraform installed, or a tool installed in a shell-rc-only path (e.g. ~/.local/bin added by .bashrc) that act's environment does not include; also commands installed only inside containers while running -self-hosted.","commonSituations":"Switching a workflow from container to -self-hosted mode and assuming tools from the container image exist on the host; tools installed via user-level managers (cargo, npm -g with a prefix, asdf, mise) whose shims live outside act's PATH; macOS/Linux differences in default PATH; CI agents with minimal PATHs.","solutions":["Install the missing tool on the host and ensure its bin directory is on PATH (verify with 'act -P ...=-self-hosted' then 'which <cmd>' in a debug step: 'run: echo $PATH; command -v <cmd>').","Set PATH explicitly at the job or step level: 'env: PATH: /home/runner/.local/bin:$PATH' (or prepend in the run script).","Use absolute paths to the binary in the run step if the location is known.","Prefer running the workflow in a container image that already contains the tool instead of host mode."],"exampleFix":"# before\n- run: terraform plan\n# host mode: Cannot find: terraform in PATH\n\n# after\n- run: terraform plan\n  env:\n    PATH: /opt/homebrew/bin:/usr/local/bin:/home/runner/.local/bin:${PATH}","handlingStrategy":"validation","validationCode":"// Verify a tool is resolvable with the env act will use, before the step runs\npackage main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"os/exec\"\n)\n\nfunc checkToolOnPath(tool string, env map[string]string) error {\n\tcmd := exec.Command(\"sh\", \"-c\", \"command -v \"+tool)\n\tcmd.Env = os.Environ()\n\tfor k, v := range env {\n\t\tcmd.Env = append(cmd.Env, k+\"=\"+v)\n\t}\n\tif out, err := cmd.Output(); err != nil {\n\t\treturn fmt.Errorf(\"%s not on PATH under job env; install it or extend PATH\", tool)\n\t} else {\n\t\tfmt.Printf(\"%s resolves to %s\\n\", tool, out)\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":"if err := stepExecutor(ctx); err != nil {\n    if strings.Contains(err.Error(), \"Cannot find:\") && strings.Contains(err.Error(), \"in PATH\") {\n        cmd := strings.TrimPrefix(strings.Split(err.Error(), \" in PATH\")[0], \"Cannot find: \")\n        return fmt.Errorf(\"install %s on the host or prepend its directory to PATH in the step env\", cmd)\n    }\n    return err\n}","preventionTips":["Add a debug step 'run: echo $PATH; command -v <tool>' before failing steps in host mode.","Set PATH explicitly in job env when tools live in user-local bin dirs.","Prefer container images that bundle required tools over host execution."],"tags":["host-execution","path","self-hosted","environment"],"backgroundTag":null,"analyzedSha":"4f411281417e88660bea1c1a1749aa71ae0bd60f","analyzedAt":"2026-08-15T09:19:46.307Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}