{"record":{"id":"cd2470ca489e5290","repo":"phacility/phabricator","slug":"config-option-phd-user-is-not-set-you-must-set","errorCode":null,"errorMessage":"Config option \"phd.user\" is not set. You must set this option so the private key can be stored with the correct permissions.","messagePattern":"Config option \"phd\\.user\" is not set\\. You must set this option so the private key can be stored with the correct permissions\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"error","filePath":"src/applications/almanac/management/AlmanacManagementRegisterWorkflow.php","lineNumber":87,"sourceCode":"          'No such device \"%s\" exists!', $raw_device));\n    }\n\n    $private_key_path = $args->getArg('private-key');\n    if (!strlen($private_key_path)) {\n      throw new PhutilArgumentUsageException(\n        pht('Specify a private key with --private-key.'));\n    }\n\n    if (!Filesystem::pathExists($private_key_path)) {\n      throw new PhutilArgumentUsageException(\n        pht('No private key exists at path \"%s\"!', $private_key_path));\n    }\n\n    $raw_private_key = Filesystem::readFile($private_key_path);\n\n    $phd_user = PhabricatorEnv::getEnvConfig('phd.user');\n    if (!$phd_user) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Config option \"phd.user\" is not set. You must set this option '.\n          'so the private key can be stored with the correct permissions.'));\n    }\n\n    $tmp = new TempFile();\n    list($err) = exec_manual('chown %s %s', $phd_user, $tmp);\n    if ($err) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Unable to change ownership of an identity file to daemon user '.\n          '\"%s\". Run this command as %s or root.',\n          $phd_user,\n          $phd_user));\n    }\n\n    $stored_public_path = AlmanacKeys::getKeyPath('device.pub');\n    $stored_private_path = AlmanacKeys::getKeyPath('device.key');","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/almanac/management/AlmanacManagementRegisterWorkflow.php#L69-L105","documentation":"Usage exception from `bin/almanac register`: the Phabricator config option phd.user is empty. The workflow must chown the copied private key and identity files to the daemon user so the phd daemons (and the host identity they manage) can read them, so registration refuses to continue without that configuration.","triggerScenarios":"Fresh install where phd.user was never set; bin/config set phd.user executed against a different instance/environment than the one register runs against; the config was reverted during an upgrade or migration.","commonSituations":"New cluster builds following the 'Almanac Cluster' setup docs, which require phd.user before registering devices; multi-instance servers where the wrong PHABRICATOR_ENV picks a config without the setting;容器化 deployments that regenerate config and drop the option.","solutions":["Set the daemon user: bin/config set phd.user <daemon-user> (commonly 'phd-daemon' or a dedicated account), then rerun register.","Make sure that user exists on the host (getent passwd <daemon-user>) before registering.","Verify you are configuring the same instance the CLI targets (check PHABRICATOR_ENV / phabricator.env when multiple exist)."],"exampleFix":"# before\n$ bin/almanac register --device web-001 --private-key ./device.key\nUsage Exception: Config option \"phd.user\" is not set. ...\n\n# after\n$ bin/config set phd-user phd-daemon   # or: bin/config set phd.user phd-daemon per version\n$ bin/almanac register --device web-001 --private-key ./device.key","handlingStrategy":"validation","validationCode":"$phd_user = PhabricatorEnv::getEnvConfig('phd.user');\nif (!strlen((string)$phd_user)) {\n  throw new RuntimeException(\n    'phd.user is not set; run: bin/config set phd.user <daemon-user>');\n}","typeGuard":null,"tryCatchPattern":"# shell preflight before any register\nbin/config get phd.user | grep -q . || bin/config set phd.user phd-daemon","preventionTips":["Include `bin/config set phd.user ...` in the standard Almanac/cluster bootstrap script.","Validate required config (phd.user, almanac namespaces) as a preflight step in provisioning.","After instance migrations/upgrades, diff config against your baseline."],"tags":["phabricator","almanac","config","cli","register","setup"],"backgroundTag":"missing-config-option","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}