GoogleContainerTools/skaffold · error
`exec` requires exactly one action to execute
Error message
`exec` requires exactly one action to execute
What it means
Skaffold's `exec` command runs exactly one named action defined in skaffold.yaml. The Args validator requires len(args) == 1; zero or multiple arguments produce this error. The message is also logged via log.Entry before being returned.
Source
Thrown at cmd/skaffold/app/cmd/exec.go:46
"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/output/log"
"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/runner"
"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/latest"
"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/util"
)
// NewCmdExec describes the CLI command to execute a custom action.
func NewCmdExec() *cobra.Command {
return NewCmd("exec").
WithDescription("Execute a custom action").
WithExample("Execute a defined action", "exec <action-name>").
WithExample("Execute a defined action that uses an image built from Skaffold. First, build the images", "build --file-output=build.json").
WithExample("Then use the built artifacts", "exec <action-name> --build-artifacts=build.json").
WithCommonFlags().
WithHouseKeepingMessages().
WithArgs(func(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
log.Entry(context.TODO()).Errorf("`exec` requires exactly one action to execute")
return errors.New("`exec` requires exactly one action to execute")
}
return nil
}, doExec)
}
func doExec(ctx context.Context, out io.Writer, args []string) error {
return withRunner(ctx, out, func(r runner.Runner, configs []util.VersionedConfig) error {
buildArtifacts, err := getBuildArtifactsAndSetTagsForAction(configs, r.ApplyDefaultRepo, args[0])
if err != nil {
tips.PrintUseBuildAndExec(out)
return err
}
return r.Exec(ctx, out, buildArtifacts, args[0])
})
}
func getBuildArtifactsAndSetTagsForAction(configs []util.VersionedConfig, defaulterFn DefaultRepoFn, action string) ([]graph.Artifact, error) {
imgs := getActionImgs(action, configs)View on GitHub (pinned to a1189de023)
Solutions
- Invoke with exactly one action name: `skaffold exec <action-name>`
- Quote names containing spaces: `skaffold exec "my action"`
- List available actions in skaffold.yaml (`actions:` section) and pick one
Example fix
// before skaffold exec --build-artifacts=build.json // after skaffold exec build-and-test --build-artifacts=build.json
Defensive patterns
Strategy: validation
Validate before calling
ACTION=$(echo "$ACTION" | xargs) # normalize; then:
[ $# -eq 1 ] || { echo "usage: skaffold exec <action-name>"; exit 1; } Prevention
- Quote action names so shell splitting keeps args count at exactly 1
- Verify the action exists in the `actions:` section of skaffold.yaml
- Place flags before the single positional argument
When it happens
Trigger: Running `skaffold exec` with no action name, or `skaffold exec action-a action-b` with more than one positional argument. Also triggered when a quoted action name accidentally splits into multiple args.
Common situations: Forgetting the action name after flags (`exec --build-artifacts=build.json`); passing extra tokens like `exec run my-action`; shell word-splitting on an unquoted variable.
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
- `config-dependencies add` requires exactly one file path arg
- `jobManifestPaths modify` requires exactly one manifest file
- `inspect namespaces list` requires exactly one manifest file
- running diagnostic on artifacts: %w
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/84551500143f4a8d.
Report an issue: GitHub.