phacility/phabricator · error · PhutilArgumentUsageException
Output path already exists. Use "--overwrite" to overwrite i
Error message
Output path already exists. Use "--overwrite" to overwrite it.
What it means
The export workflow will not clobber an existing file unless told to. When the destination path exists (Filesystem::pathExists), --output is not stdout, and --overwrite was not passed, this usage exception is thrown. It protects existing data from being replaced by a re-run.
Source
Thrown at src/applications/transactions/bulk/management/PhabricatorBulkManagementExportWorkflow.php:101
'Use "--output <path>" to specify an output file, or "--output -" '.
'to print to stdout.'));
}
if ($output_path === '-') {
$is_stdout = true;
} else {
$is_stdout = false;
}
if ($is_stdout && $is_overwrite) {
throw new PhutilArgumentUsageException(
pht(
'Flag "--overwrite" has no effect when outputting to stdout.'));
}
if (!$is_overwrite) {
if (!$is_stdout && Filesystem::pathExists($output_path)) {
throw new PhutilArgumentUsageException(
pht(
'Output path already exists. Use "--overwrite" to overwrite '.
'it.'));
}
}
// If we have more than one query, execute the queries to figure out which
// results they hit, then build a synthetic query for all those results
// using the IDs.
if (count($queries) > 1) {
$saved_query = $this->newUnionQuery($engine, $queries);
} else {
$saved_query = head($queries);
}
$export_engine = id(new PhabricatorExportEngine())
->setViewer($viewer)
->setTitle(pht('Export'))View on GitHub (pinned to 5720a38cfe)
Solutions
- Add --overwrite to the command if replacing the file is intended.
- Export to a fresh path, e.g. one containing a timestamp: --output tasks-$(date +%F).csv.
- Remove or move the existing file before the export runs.
Example fix
# before bin/bulk export --query all --output /tmp/tasks.csv # after (if replacing the file is intended) bin/bulk export --query all --output /tmp/tasks.csv --overwrite
Defensive patterns
Strategy: validation
Validate before calling
if [[ -e "$DEST" && "$ALLOW_OVERWRITE" != 1 ]]; then echo "output already exists: $DEST" >&2; exit 2 fi
Prevention
- Use unique, timestamped output filenames in scheduled exports.
- Decide explicitly per script whether overwrite is allowed.
- Add a pre-flight test -e check so failures happen before the query runs.
When it happens
Trigger: Running an export to a path that already exists from a previous run, without --overwrite. Also triggered when the path exists as a directory, since pathExists matches any filesystem entry.
Common situations: Repeated cron exports writing to a fixed filename; an earlier failed run left a partial file; shared mounts (NFS, docker volumes) where another process created the file.
Related errors
- Use "--output <path>" to specify an output file, or "--outpu
- Flag "--overwrite" has no effect when outputting to stdout.
- Specify one or more queries to export with "--query".
- No search engines match "%s". Available engines which suppor
- Multiple search engines match "%s": %s.
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/95c66d0b189b3df5.
Report an issue: GitHub.