{"record":{"id":"3c46656ae3bbeb38","repo":"derailed/k9s","slug":"kubectl-command-is-not-in-your-path-w","errorCode":null,"errorMessage":"kubectl command is not in your path: %w","messagePattern":"kubectl command is not in your path: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/view/exec.go","lineNumber":64,"sourceCode":"type shellOpts struct {\n\tclear, background bool\n\tpipes             []string\n\tbinary            string\n\tbanner            string\n\targs              []string\n}\n\nfunc (s shellOpts) String() string {\n\treturn fmt.Sprintf(\"%s %s\", s.binary, strings.Join(s.args, \" \"))\n}\n\nfunc runK(a *App, opts *shellOpts) error {\n\tbin, err := exec.LookPath(\"kubectl\")\n\tif errors.Is(err, exec.ErrDot) {\n\t\treturn fmt.Errorf(\"kubectl command must not be in the current working directory: %w\", err)\n\t}\n\tif err != nil {\n\t\treturn fmt.Errorf(\"kubectl command is not in your path: %w\", err)\n\t}\n\targs := []string{opts.args[0]}\n\tif u, err := a.Conn().Config().ImpersonateUser(); err == nil {\n\t\targs = append(args, \"--as\", u)\n\t}\n\tif g, err := a.Conn().Config().ImpersonateGroups(); err == nil {\n\t\targs = append(args, \"--as-group\", g)\n\t}\n\tif isInsecure := a.Conn().Config().Flags().Insecure; isInsecure != nil && *isInsecure {\n\t\targs = append(args, \"--insecure-skip-tls-verify\")\n\t}\n\targs = append(args, \"--context\", a.Config.K9s.ActiveContextName())\n\tif cfg := a.Conn().Config().Flags().KubeConfig; cfg != nil && *cfg != \"\" {\n\t\targs = append(args, \"--kubeconfig\", *cfg)\n\t}\n\tif len(args) > 0 {\n\t\topts.args = append(args, opts.args[1:]...)\n\t}","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/derailed/k9s/blob/2d3ccc6ba2ce98c3781bfc441bb3e884f072774f/internal/view/exec.go#L46-L82","documentation":"exec.LookPath(\"kubectl\") returned a non-sentinel error: no kubectl executable exists anywhere on PATH. runK() backs every feature where k9s shells out to kubectl (in-pod shell, node shell plumbing, kubectl prompt commands), so those features are dead until kubectl is installed.","triggerScenarios":"Pressing 's' (shell) on a container or running a :!kubectl ... command on a workstation where kubectl is not installed, not executable, or PATH inside the k9s process differs from the login shell (launched from a GUI launcher, snap wrapper, or service with a minimal PATH).","commonSituations":"New machines without the CLI; kubectl installed via asdf/nvm shim not on the GUI session's PATH; container images running k9s without kubectl; typo'd PATH in shell rc files.","solutions":["Verify in the same environment: kubectl version --client","Install kubectl to a directory on PATH (https://kubernetes.io/docs/tasks/tools/), then restart the terminal and k9s","If installed via a version manager, ensure its bin dir is exported in the environment k9s actually inherits (check with :!echo $PATH inside k9s)"],"exampleFix":"# before\n$ k9s  # shell command fails: kubectl not in PATH\n$ which kubectl\n(not found)\n# after\n$ curl -LO \"https://dl.k8s.io/release/$(curl -Ls https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl\"\n$ sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl\n$ k9s","handlingStrategy":"validation","validationCode":"if _, err := exec.LookPath(\"kubectl\"); err != nil {\n    return fmt.Errorf(\"kubectl not found on PATH %q — install it before using shell features\", os.Getenv(\"PATH\"))\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify kubectl version --client in the exact environment k9s inherits (GUI launchers strip PATH)","Install kubectl before relying on k9s shell/exec features","Use :!echo $PATH inside k9s to confirm the process sees your PATH"],"tags":["kubernetes","k9s","exec","path","environment"],"backgroundTag":null,"analyzedSha":"2d3ccc6ba2ce98c3781bfc441bb3e884f072774f","analyzedAt":"2026-08-15T16:09:14.432Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}