GoogleContainerTools/skaffold · error
missing shell: %s
Error message
missing shell: %s
What it means
In `skaffold completion` (cmd/skaffold/app/cmd/completion.go:70), the cobra Args validator requires exactly one argument naming a shell. When zero or multiple arguments are given, this error is returned listing the valid shells (bash, fish, zsh) before cobra's OnlyValidArgs check runs.
Source
Thrown at cmd/skaffold/app/cmd/completion.go:70
func completion(cmd *cobra.Command, args []string) {
switch args[0] {
case "bash":
rootCmd(cmd).GenBashCompletion(os.Stdout)
case "fish":
rootCmd(cmd).GenFishCompletion(os.Stdout, true)
case "zsh":
runCompletionZsh(cmd, os.Stdout)
}
}
// NewCmdCompletion returns the cobra command that outputs shell completion code
func NewCmdCompletion() *cobra.Command {
return &cobra.Command{
Use: "completion SHELL",
Args: func(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
return fmt.Errorf("missing shell: %s", strings.Join(cmd.ValidArgs, ", "))
}
return cobra.OnlyValidArgs(cmd, args)
},
ValidArgs: []string{"bash", "fish", "zsh"},
Short: "Output shell completion for the given shell (bash, fish or zsh)",
Long: longDescription,
Run: completion,
}
}
func runCompletionZsh(cmd *cobra.Command, out io.Writer) {
rootCmd(cmd).GenZshCompletion(out)
io.WriteString(out, zshCompdef)
}
func rootCmd(cmd *cobra.Command) *cobra.Command {
parent := cmd
for parent.HasParent() {View on GitHub (pinned to a1189de023)
Solutions
- Pass exactly one supported shell: `skaffold completion bash` (or fish, zsh)
- Fix aliases/scripts that invoke completion without the shell argument
- Source the output, e.g. `source <(skaffold completion bash)` in your shell rc
- Check `skaffold completion --help` for the shells supported by your skaffold version
Example fix
// before // skaffold completion # missing shell // after // skaffold completion bash | source /dev/stdin # or add to ~/.bashrc
Defensive patterns
Strategy: validation
Validate before calling
// Validate the shell argument before invoking completion
validShells := map[string]bool{"bash": true, "fish": true, "zsh": true}
if !validShells[shell] {
return fmt.Errorf("unsupported shell %q; use bash, fish or zsh", shell)
} Type guard
func isSupportedShell(s string) bool {
switch s {
case "bash", "fish", "zsh":
return true
}
return false
} Try / catch
if err := sh.Run("skaffold", "completion", shell); err != nil {
if strings.Contains(err.Error(), "missing shell") {
log.Fatalf("pass exactly one shell: skaffold completion <bash|fish|zsh>")
}
return err
} Prevention
- Always pass exactly one shell argument to `skaffold completion`
- Check --help for supported shells on your skaffold version
- Guard shell rc setup scripts with an argument check
- Remember powershell is not supported here; use bash/zsh/fish only
When it happens
Trigger: Running `skaffold completion` with no argument, or with more than one argument (e.g. `skaffold completion bash zsh`); len(args) != 1 triggers the error message joined from cmd.ValidArgs.
Common situations: Older documentation or muscle memory from tools whose completion command takes no argument; shell alias dropping the argument; copy-pasting a command with an extra token; expecting powershell support which is not in ValidArgs.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- `apply` requires at least one manifest argument
- `exec` requires exactly one action to execute
- `config-dependencies add` requires exactly one file path arg
- `jobManifestPaths modify` requires exactly one manifest file
- `inspect namespaces list` requires exactly one manifest file
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/030a742c316a099b.
Report an issue: GitHub.