phacility/phabricator · error · PhutilArgumentUsageException
Specify a command to run.
Error message
Specify a command to run.
What it means
A PhutilArgumentUsageException from `bin/drydock command` when --lease is provided but no command (argv) follows. The workflow executes an arbitrary command on the leased resource via its command interface, so an empty wildcard argument list is rejected before the lease is even loaded.
Solutions
- Append the command and its arguments after a `--` separator: `bin/drydock command --lease 42 -- ls -la`.
- In scripts, verify the argv array is non-empty before invoking the workflow.
Example fix
# before bin/drydock command --lease 42 # after bin/drydock command --lease 42 -- ls -la /
Defensive patterns
Strategy: validation
Validate before calling
if (count($argv) === 0) {
throw new InvalidArgumentException('No command given for drydock command.');
}
$cmd = array_merge(
array('bin/drydock', 'command', '--lease', (string)$lease_id, '--'),
$argv); Prevention
- Always terminate flags with `--` before the command so argv is parsed as command words.
- When building argv programmatically, fail fast if the array is empty.
When it happens
Trigger: Running `bin/drydock command --lease 42` with nothing after the flag, or putting the command before the flags so PhutilArgumentParser consumes it as an option value.
Common situations: Quoting mistakes in scripts that build argv dynamically and end up with an empty array; forgetting the trailing `--` separator so the intended command is parsed as flags.
Understand the failure class
Background: "no subcommand specified" and "... is required": CLI errors when a required argument is missing — this error's family across 13 libraries.
Related errors
- Specify a resource type with "--type".
- Use "--lease" to specify a lease.
- Blueprint " " could not be loaded. Try a blueprint ID or…
- Blueprint " " is specified more than once (as " " and " ").
- Choose a policy with
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/fb138a286e61e849.
Report an issue: GitHub.
Appendix: source
Thrown at src/applications/drydock/management/DrydockManagementCommandWorkflow.php:35
array(
'name' => 'argv',
'wildcard' => true,
'help' => pht('Command to execute.'),
),
));
}
public function execute(PhutilArgumentParser $args) {
$lease_id = $args->getArg('lease');
if (!$lease_id) {
throw new PhutilArgumentUsageException(
pht(
'Use "--lease" to specify a lease.'));
}
$argv = $args->getArg('argv');
if (!$argv) {
throw new PhutilArgumentUsageException(
pht(
'Specify a command to run.'));
}
$lease = id(new DrydockLeaseQuery())
->setViewer($this->getViewer())
->withIDs(array($lease_id))
->executeOne();
if (!$lease) {
throw new Exception(
pht(
'Unable to load lease with ID "%s"!',
$lease_id));
}
// TODO: Check lease state, etc.
$interface = $lease->getInterface(DrydockCommandInterface::INTERFACE_TYPE);View on GitHub (pinned to 5720a38cfe)