{"record":{"id":"03d663d43851b9a9","repo":"phacility/phabricator","slug":"failed-to-create-directory-s-for-specified-pid","errorCode":null,"errorMessage":"Failed to create directory \"%s\" for specified PID file. You should manually create this directory or choose a different PID file location. %s","messagePattern":"Failed to create directory \"(.+?)\" for specified PID file\\. You should manually create this directory or choose a different PID file location\\. (.+?)","errorType":"exception","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"error","filePath":"src/applications/aphlict/management/PhabricatorAphlictManagementWorkflow.php","lineNumber":283,"sourceCode":"            'once (at indexes \"%s\" and \"%s\"). Each peer must have a '.\n            'unique host and port combination.',\n            $peer_key,\n            $peer_map[$peer_key],\n            $index));\n      }\n    }\n\n    $this->configData = $data;\n    $this->configPath = $full_path;\n\n    $pid_path = $this->getPIDPath();\n    try {\n      $dir = dirname($pid_path);\n      if (!Filesystem::pathExists($dir)) {\n        Filesystem::createDirectory($dir, 0755, true);\n      }\n    } catch (FilesystemException $ex) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Failed to create directory \"%s\" for specified PID file. You '.\n          'should manually create this directory or choose a different '.\n          'PID file location. %s',\n          $dir,\n          $ex->getMessage()));\n    }\n  }\n\n  final public function getPIDPath() {\n    return $this->configData['pidfile'];\n  }\n\n  final public function getPID() {\n    $pid = null;\n    if (Filesystem::pathExists($this->getPIDPath())) {\n      $pid = (int)Filesystem::readFile($this->getPIDPath());\n    }","sourceCodeStart":265,"sourceCodeEnd":301,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/aphlict/management/PhabricatorAphlictManagementWorkflow.php#L265-L301","documentation":"Thrown at the end of Aphlict config validation when creating the parent directory of the configured 'pidfile' fails (Filesystem::createDirectory threw). This is the same pattern as the log-directory check, applied to the PID file location, with the underlying FilesystemException message appended.","triggerScenarios":"\"pidfile\": \"/var/run/aphlict/aphlict.pid\" with /var/run/aphlict not existing and the service user lacking permission to create directories under /var/run (root-owned in most distros).","commonSituations":"Moving the pidfile under /var/run for init/systemd integration while running aphlict as a non-root user; /run being a tmpfs wiped on reboot so the directory disappears after restarts.","solutions":["Pre-create and hand over the directory: sudo mkdir -p /var/run/aphlict && sudo chown <aphlict-user> /var/run/aphlict (make it part of the service startup, since /run is tmpfs)","Or use a user-writable pidfile path such as /var/tmp/aphlict.pid or a systemd RuntimeDirectory","With systemd, prefer RuntimeDirectory=aphlict over a static pidfile path"],"exampleFix":"# before: \"pidfile\": \"/var/run/aphlict/aphlict.pid\", dir missing\nsudo mkdir -p /var/run/aphlict && sudo chown aphlict:aphlict /var/run/aphlict\n# after: bin/aphlict start proceeds","handlingStrategy":"validation","validationCode":"$dir = dirname($config['pidfile']);\nif (!Filesystem::pathExists($dir) && !is_writable(dirname($dir))) {\n  throw new InvalidArgumentException(\"Cannot create PID directory {$dir}: check permissions\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Create the PID directory as part of service startup (tmpfs /run disappears on reboot)","Prefer systemd RuntimeDirectory= or a user-writable path over /var/run subdirectories"],"tags":["aphlict","filesystem","permissions","pidfile","phabricator"],"backgroundTag":"filesystem-permission-denied","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}