phacility/phabricator · warning · PhutilArgumentUsageException

Output file "%s" already exists. Use "--overwrite" to overwr

Error message

Output file "%s" already exists. Use "--overwrite" to overwrite.

What it means

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.

Source

Thrown at src/infrastructure/storage/management/workflow/PhabricatorStorageManagementRenamespaceWorkflow.php:101

    }


    $output_file = $args->getArg('output');
    $is_overwrite = $args->getArg('overwrite');
    $is_compress = $args->getArg('compress');

    if ($is_overwrite) {
      if ($output_file === null) {
        throw new PhutilArgumentUsageException(
          pht(
            'The "--overwrite" flag can only be used alongside "--output".'));
      }
    }

    if ($output_file !== null) {
      if (Filesystem::pathExists($output_file)) {
        if (!$is_overwrite) {
          throw new PhutilArgumentUsageException(
            pht(
              'Output file "%s" already exists. Use "--overwrite" '.
              'to overwrite.',
              $output_file));
        }
      }
    }

    if ($is_live) {
      $api = $this->getSingleAPI();
      $ref_key = $api->getRef()->getRefKey();

      $root = dirname(phutil_get_library_root('phabricator'));

      $future = new ExecFuture(
        '%R dump --ref %s',
        $root.'/bin/storage',
        $ref_key);

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Add `--overwrite` when replacing the file is intended.
  2. Or move the old file aside (`mv out.sql out.sql.bak`) and re-run.
  3. Or generate a unique name per run: `--output renamed-$(date +%s).sql`.

Example fix

# before
./bin/storage renamespace --input d.sql --from a --to b --output /tmp/out.sql

# after (choose one)
./bin/storage renamespace --input d.sql --from a --to b --output /tmp/out.sql --overwrite
# or
rm /tmp/out.sql && ./bin/storage renamespace --input d.sql --from a --to b --output /tmp/out.sql
Defensive patterns

Strategy: validation

Validate before calling

if [ -e "$OUT" ] && [ -z "$OVERWRITE" ]; then
  echo "error: $OUT exists; pass --overwrite or move it aside" >&2
  exit 2
fi

Prevention

When it happens

Trigger: Passing `--output <existing-path>` without `--overwrite`, so the pathExists check trips inside the !$is_overwrite branch.

Common situations: 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.

Related errors


AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21). Data as JSON: /api/errors/9c0277e1c491399b. Report an issue: GitHub.