{"record":{"id":"0d384eb2186d0a43","repo":"GoogleContainerTools/skaffold","slug":"overwrite-and-output-o-cannot-be-used-togethe","errorCode":null,"errorMessage":"--overwrite and --output/-o cannot be used together","messagePattern":"--overwrite and --output/-o cannot be used together","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"cmd/skaffold/app/cmd/fix.go","lineNumber":61,"sourceCode":"func NewCmdFix() *cobra.Command {\n\treturn NewCmd(\"fix\").\n\t\tWithDescription(\"Update old configuration to a newer schema version\").\n\t\tWithExample(\"Update \\\"skaffold.yaml\\\" in the current folder to the latest version\", \"fix\").\n\t\tWithExample(\"Update \\\"skaffold.yaml\\\" in the current folder to version \\\"skaffold/v1\\\"\", \"fix --version skaffold/v1\").\n\t\tWithExample(\"Update \\\"skaffold.yaml\\\" in the current folder in-place\", \"fix --overwrite\").\n\t\tWithExample(\"Update \\\"skaffold.yaml\\\" and write the output to a new file\", \"fix --output skaffold.new.yaml\").\n\t\tWithCommonFlags().\n\t\tWithFlags([]*Flag{\n\t\t\t{Value: &overwrite, Name: \"overwrite\", DefValue: false, Usage: \"Overwrite original config with fixed config\"},\n\t\t\t{Value: &toVersion, Name: \"version\", DefValue: latest.Version, Usage: \"Target schema version to upgrade to\"},\n\t\t\t{Value: &fixOutputPath, Name: \"output\", Shorthand: \"o\", DefValue: \"\", Usage: \"File to write the changed config (instead of standard output)\"},\n\t\t}).\n\t\tNoArgs(doFix)\n}\n\nfunc doFix(_ context.Context, out io.Writer) error {\n\tif overwrite && fixOutputPath != \"\" {\n\t\treturn fmt.Errorf(\"--overwrite and --output/-o cannot be used together\")\n\t}\n\tvar toFile string\n\tif fixOutputPath != \"\" {\n\t\ttoFile = fixOutputPath\n\t} else if overwrite {\n\t\ttoFile = opts.ConfigurationFile\n\t}\n\treturn fix(out, opts.ConfigurationFile, toFile, toVersion, overwrite)\n}\n\nfunc fix(out io.Writer, configFile, outFile string, toVersion string, overwrite bool) error {\n\tparsedCfgs, err := schema.ParseConfig(configFile)\n\tif err != nil {\n\t\treturn err\n\t}\n\tneedsUpdate := false\n\tfor _, cfg := range parsedCfgs {\n\t\tif cfg.GetVersion() != toVersion {","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/cmd/skaffold/app/cmd/fix.go#L43-L79","documentation":"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.","triggerScenarios":"doFix is invoked with overwrite=true and fixOutputPath non-empty (user passed both --overwrite and --output/-o), triggering the guard at fix.go:61.","commonSituations":"Scripted skaffold fix calls that accumulate flags, or users combining flags to try to overwrite and back up at once.","solutions":["Use only --overwrite to fix skaffold.yaml in place","Or use only --output/-o to write the upgraded config to a new file","To keep a backup, copy skaffold.yaml first, then run with --overwrite"],"exampleFix":"// before\nskaffold fix --overwrite --output skaffold-new.yaml\n// error: --overwrite and --output/-o cannot be used together\n// after\ncp skaffold.yaml skaffold.yaml.bak && skaffold fix --overwrite","handlingStrategy":"validation","validationCode":"if overwrite && fixOutputPath != \"\" {\n    return fmt.Errorf(\"--overwrite and --output/-o cannot be used together\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pick one output mode: --overwrite OR --output","In scripts, pass flags conditionally instead of accumulating them","Copy skaffold.yaml to a backup before using --overwrite"],"tags":["cli","flag-conflict","validation"],"backgroundTag":"conflicting-flags","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}