GoogleContainerTools/skaffold · warning

--overwrite and --output/-o cannot be used together

Error message

--overwrite and --output/-o cannot be used together

What it means

Validation error in doFix: `skaffold fix` refuses to run when both --overwrite (fix skaffold.yaml in place) and --output/-o (write to another path) are provided, since they specify conflicting output destinations.

Source

Thrown at cmd/skaffold/app/cmd/fix.go:61

func NewCmdFix() *cobra.Command {
	return NewCmd("fix").
		WithDescription("Update old configuration to a newer schema version").
		WithExample("Update \"skaffold.yaml\" in the current folder to the latest version", "fix").
		WithExample("Update \"skaffold.yaml\" in the current folder to version \"skaffold/v1\"", "fix --version skaffold/v1").
		WithExample("Update \"skaffold.yaml\" in the current folder in-place", "fix --overwrite").
		WithExample("Update \"skaffold.yaml\" and write the output to a new file", "fix --output skaffold.new.yaml").
		WithCommonFlags().
		WithFlags([]*Flag{
			{Value: &overwrite, Name: "overwrite", DefValue: false, Usage: "Overwrite original config with fixed config"},
			{Value: &toVersion, Name: "version", DefValue: latest.Version, Usage: "Target schema version to upgrade to"},
			{Value: &fixOutputPath, Name: "output", Shorthand: "o", DefValue: "", Usage: "File to write the changed config (instead of standard output)"},
		}).
		NoArgs(doFix)
}

func doFix(_ context.Context, out io.Writer) error {
	if overwrite && fixOutputPath != "" {
		return fmt.Errorf("--overwrite and --output/-o cannot be used together")
	}
	var toFile string
	if fixOutputPath != "" {
		toFile = fixOutputPath
	} else if overwrite {
		toFile = opts.ConfigurationFile
	}
	return fix(out, opts.ConfigurationFile, toFile, toVersion, overwrite)
}

func fix(out io.Writer, configFile, outFile string, toVersion string, overwrite bool) error {
	parsedCfgs, err := schema.ParseConfig(configFile)
	if err != nil {
		return err
	}
	needsUpdate := false
	for _, cfg := range parsedCfgs {
		if cfg.GetVersion() != toVersion {

View on GitHub (pinned to a1189de023)

Solutions

  1. Use only --overwrite to fix skaffold.yaml in place
  2. Or use only --output/-o to write the upgraded config to a new file
  3. To keep a backup, copy skaffold.yaml first, then run with --overwrite

Example fix

// before
skaffold fix --overwrite --output skaffold-new.yaml
// error: --overwrite and --output/-o cannot be used together
// after
cp skaffold.yaml skaffold.yaml.bak && skaffold fix --overwrite
Defensive patterns

Strategy: validation

Validate before calling

if overwrite && fixOutputPath != "" {
    return fmt.Errorf("--overwrite and --output/-o cannot be used together")
}

Prevention

When it happens

Trigger: doFix is invoked with overwrite=true and fixOutputPath non-empty (user passed both --overwrite and --output/-o), triggering the guard at fix.go:61.

Common situations: Scripted skaffold fix calls that accumulate flags, or users combining flags to try to overwrite and back up at once.

Related errors


AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05). Data as JSON: /api/errors/0d384eb2186d0a43. Report an issue: GitHub.