{"record":{"id":"9c0277e1c491399b","repo":"phacility/phabricator","slug":"output-file-s-already-exists-use-overwrite-9c0277","errorCode":null,"errorMessage":"Output file \"%s\" already exists. Use \"--overwrite\" to overwrite.","messagePattern":"Output file \"(.+?)\" already exists\\. Use \"--overwrite\" to overwrite\\.","errorType":"exception","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/infrastructure/storage/management/workflow/PhabricatorStorageManagementRenamespaceWorkflow.php","lineNumber":101,"sourceCode":"    }\n\n\n    $output_file = $args->getArg('output');\n    $is_overwrite = $args->getArg('overwrite');\n    $is_compress = $args->getArg('compress');\n\n    if ($is_overwrite) {\n      if ($output_file === null) {\n        throw new PhutilArgumentUsageException(\n          pht(\n            'The \"--overwrite\" flag can only be used alongside \"--output\".'));\n      }\n    }\n\n    if ($output_file !== null) {\n      if (Filesystem::pathExists($output_file)) {\n        if (!$is_overwrite) {\n          throw new PhutilArgumentUsageException(\n            pht(\n              'Output file \"%s\" already exists. Use \"--overwrite\" '.\n              'to overwrite.',\n              $output_file));\n        }\n      }\n    }\n\n    if ($is_live) {\n      $api = $this->getSingleAPI();\n      $ref_key = $api->getRef()->getRefKey();\n\n      $root = dirname(phutil_get_library_root('phabricator'));\n\n      $future = new ExecFuture(\n        '%R dump --ref %s',\n        $root.'/bin/storage',\n        $ref_key);","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementRenamespaceWorkflow.php#L83-L119","documentation":"The path given with `--output` already exists (Filesystem::pathExists returned true) and `--overwrite` was not passed, so renamespace refuses to clobber the existing file. The guard protects previous dumps; a PhutilArgumentUsageException is thrown and nothing is written.","triggerScenarios":"Passing `--output <existing-path>` without `--overwrite`, so the pathExists check trips inside the !$is_overwrite branch.","commonSituations":"Re-running the same command with a fixed output name after a successful earlier run; CI or cron writing to a stale artifact path; output files left by a previous manual attempt.","solutions":["Add `--overwrite` when replacing the file is intended.","Or move the old file aside (`mv out.sql out.sql.bak`) and re-run.","Or generate a unique name per run: `--output renamed-$(date +%s).sql`."],"exampleFix":"# before\n./bin/storage renamespace --input d.sql --from a --to b --output /tmp/out.sql\n\n# after (choose one)\n./bin/storage renamespace --input d.sql --from a --to b --output /tmp/out.sql --overwrite\n# or\nrm /tmp/out.sql && ./bin/storage renamespace --input d.sql --from a --to b --output /tmp/out.sql","handlingStrategy":"validation","validationCode":"if [ -e \"$OUT\" ] && [ -z \"$OVERWRITE\" ]; then\n  echo \"error: $OUT exists; pass --overwrite or move it aside\" >&2\n  exit 2\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use timestamped output names in cron/CI to avoid collisions.","Decide deliberately whether each run overwrites; never rely on the exception as your reminder."],"tags":["phabricator","bin-storage","renamespace","cli","file-exists","usage-error"],"backgroundTag":"output-file-already-exists","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}