phacility/phabricator · warning · PhutilArgumentUsageException
Select caches to purge with "--all" or "--caches". Available
Error message
Select caches to purge with "--all" or "--caches". Available caches are: %s.
What it means
Thrown by bin/cache purge when neither --all nor --caches is supplied. The workflow refuses to guess which caches to purge, and the message enumerates the available purger keys from PhabricatorCachePurger::getAllPurgers() so you can pick one.
Source
Thrown at src/applications/cache/management/PhabricatorCacheManagementPurgeWorkflow.php:35
'name' => 'caches',
'param' => 'keys',
'help' => pht('Purge a specific set of caches.'),
),
));
}
public function execute(PhutilArgumentParser $args) {
$all_purgers = PhabricatorCachePurger::getAllPurgers();
$is_all = $args->getArg('all');
$key_list = $args->getArg('caches');
if ($is_all && phutil_nonempty_string($key_list)) {
throw new PhutilArgumentUsageException(
pht(
'Specify either "--all" or "--caches", not both.'));
} else if (!$is_all && !phutil_nonempty_string($key_list)) {
throw new PhutilArgumentUsageException(
pht(
'Select caches to purge with "--all" or "--caches". Available '.
'caches are: %s.',
implode(', ', array_keys($all_purgers))));
}
if ($is_all) {
$purgers = $all_purgers;
} else {
$key_list = preg_split('/[\s,]+/', $key_list);
$purgers = array();
foreach ($key_list as $key) {
if (isset($all_purgers[$key])) {
$purgers[$key] = $all_purgers[$key];
} else {
throw new PhutilArgumentUsageException(
pht(
'Cache purger "%s" is not recognized. Available caches '.View on GitHub (pinned to 5720a38cfe)
Solutions
- Add --all to purge every registered cache: 'bin/cache purge --all'.
- Or pass one or more keys from the list printed in the error message: 'bin/cache purge --caches general' (keys are comma/space separated).
- Re-run with no flags to make the workflow print the current valid cache key list for your install.
Example fix
// before $ bin/cache purge // after $ bin/cache purge --all
Defensive patterns
Strategy: validation
Validate before calling
$is_all = (bool)$args->getArg('all');
$caches = $args->getArg('caches');
if (!$is_all && !phutil_nonempty_string($caches)) {
// default to --all explicitly, or fail fast with guidance:
$args->setArg('all', true);
}
$valid = array_keys(PhabricatorCachePurger::getAllPurgers());
// surface $valid to the operator so they can pick a key Try / catch
try {
$workflow->execute($args);
} catch (PhutilArgumentUsageException $ex) {
fwrite(STDERR, $ex->getMessage()."\n");
exit(1);
} Prevention
- Always pass exactly one selector in scripts; never rely on a default.
- Validate flag names with --help before scheduling commands.
- Treat an empty shell variable as a hard error rather than letting the command run bare.
When it happens
Trigger: Running 'bin/cache purge' with no flags; or passing --caches with an empty string value (phutil_nonempty_string fails). A misspelled flag like --cache also leaves getArg('caches') null.
Common situations: Assuming bare 'purge' defaults to purging everything; typo'd flag names silently ignored by the argument parser; scripts written before the --caches selector existed.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Specify either "--all" or "--caches", not both.
- Cache purger "%s" is not recognized. Available caches are: %
- Request parameter "%s" is not formatted properly. Expected a
- Received "multipart/form-data" request with no "boundary".
- Expected "multipart/form-data" parse to end in state "epilog
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/f98eafbe2e80cff3.
Report an issue: GitHub.