GoogleContainerTools/skaffold · error
starting cmd: %w
Error message
starting cmd: %w
What it means
hostHook.run executes a lifecycle hook as a local process. It builds the exec.Cmd via retrieveCmd and calls cmd.Start(); if the process cannot be started (binary not found, not executable, permission denied), the error is wrapped as 'starting cmd: %w'. Note: successful Start is then followed by misc.HandleGracefulTermination for Wait.
Source
Thrown at pkg/skaffold/hooks/host.go:56
}
type Skip struct{}
func (e *Skip) Error() string {
return "host hook execution skipped."
}
// run executes the lifecycle hook on the host machine
func (h hostHook) run(ctx context.Context, in io.Reader, out io.Writer) error {
if len(h.cfg.OS) > 0 && !stringslice.Contains(h.cfg.OS, runtime.GOOS) {
log.Entry(ctx).Infof("host hook execution skipped due to OS criteria %q not matched for commands:\n%q\n", strings.Join(h.cfg.OS, ","), strings.Join(h.cfg.Command, " "))
return &Skip{}
}
cmd := h.retrieveCmd(ctx, in, out)
log.Entry(ctx).Debugf("Running command: %s", cmd.Args)
if err := cmd.Start(); err != nil {
return fmt.Errorf("starting cmd: %w", err)
}
return misc.HandleGracefulTermination(ctx, cmd)
}
func (h hostHook) retrieveCmd(ctx context.Context, in io.Reader, out io.Writer) *exec.Cmd {
cmd := exec.CommandContext(ctx, h.cfg.Command[0], h.cfg.Command[1:]...)
if in != nil {
cmd.Stdin = in
}
cmd.Stdout = out
cmd.Stderr = out
cmd.Env = append(cmd.Env, h.env...)
cmd.Env = append(cmd.Env, util.OSEnviron()...)
cmd.Dir = h.cfg.Dir
return cmd
}
View on GitHub (pinned to a1189de023)
Solutions
- Verify the command exists and is executable: which <cmd> / chmod +x <script>
- Use an absolute path (e.g. /bin/sh) or invoke via 'sh -c' in the hook command
- Test the command manually from the same environment skaffold runs in
- Fix the command array in skaffold.yaml hostHooks (args split correctly)
Example fix
// before
hostHooks:
postRender:
- command: ["notify.sh"] # not on PATH, not executable
// after
hostHooks:
postRender:
- command: ["/bin/sh", "-c", "./scripts/notify.sh"] # with chmod +x scripts/notify.sh Defensive patterns
Strategy: validation
Validate before calling
bin := h.cfg.Command[0]
if _, err := exec.LookPath(bin); err != nil {
return fmt.Errorf("host hook command %q not found on PATH", bin)
} Try / catch
err := hook.Run(ctx, out)
if err != nil && strings.Contains(err.Error(), "starting cmd") {
return fmt.Errorf("host hook failed to start; check command exists and is executable: %w", err)
} Prevention
- Use absolute paths or 'sh -c' wrappers for host hook commands
- chmod +x any script referenced by a hook
- Mirror the dev environment: test hooks where skaffold actually runs
- Keep the command array split into binary + args correctly
When it happens
Trigger: run (called by RunPostHooks) invoking cmd.Start() when h.cfg.Command[0] does not exist on PATH, is not executable, or the OS refuses to spawn the process.
Common situations: Host hook command specified with a relative path not on PATH; script without the executable bit; command present in the dev container but not on the host machine; typo in the binary name in skaffold.yaml hostHooks.
Related errors
- hook execution failed for pod %q container %q: %w
- could not start the command: %w
- starting command %v: %w
- running post-renderer: %w
- package chart into a .tgz archive: %v: %w
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/97cebf4d04a213d7.
Report an issue: GitHub.