{"record":{"id":"f7f7c495c8b9bb5c","repo":"passbolt/passbolt_api","slug":"the-file-does-not-exist-0","errorCode":null,"errorMessage":"The file does not exist: {0}","messagePattern":"The file does not exist: (.+?)","errorType":"console","errorClass":"CakeException","httpStatus":null,"severity":"error","filePath":"src/Command/KeyringInitCommand.php","lineNumber":64,"sourceCode":"    public static function getCommandDescription(): string\n    {\n        return __('GnuPG Keyring init shell for the passbolt application.');\n    }\n\n    /**\n     * @inheritDoc\n     */\n    public function execute(Arguments $args, ConsoleIo $io): ?int\n    {\n        parent::execute($args, $io);\n\n        // Root user is not allowed to execute this command.\n        $this->assertCurrentProcessUser($io, $this->processUserService);\n\n        try {\n            $filePath = Configure::read('passbolt.gpg.serverKey.private');\n            if (!file_exists($filePath)) {\n                throw new CakeException(__('The file does not exist: {0}', $filePath));\n            }\n            $armoredKey = file_get_contents($filePath);\n            if ($armoredKey === false) {\n                throw new CakeException(__('Could not read the file: {0}', $filePath));\n            }\n            // Import the private key in the OpenPGP keyring\n            $gpg = OpenPGPBackendFactory::get();\n\n            $io->out('Importing ' . $filePath);\n            $gpg->importKeyIntoKeyring($armoredKey);\n        } catch (CakeException $e) {\n            $this->error($e->getMessage(), $io);\n            $this->error('Could not import the server OpenPGP key into the keyring.', $io);\n\n            return $this->errorCode();\n        }\n\n        $this->success('Keyring init OK', $io);","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/src/Command/KeyringInitCommand.php#L46-L82","documentation":"KeyringInitCommand (bin/cake passbolt keyring init) imports the server's private GPG key into the OpenPGP keyring of the user running the command. It first reads passbolt.gpg.serverKey.private from configuration and throws if that path does not exist on disk, because importing a keyring without the server key file is impossible.","triggerScenarios":"passbolt.gpg.serverKey.private points to a missing file: server key never generated, wrong path in passbolt.php, config key unset (empty string), or file deleted/moved; also when running as a user whose filesystem view differs (but usually permission issues surface at the read step).","commonSituations":"Fresh install where 'bin/cake passbolt create_gpg_server_key' was never run; typo in passbolt.php key path; Docker volume not mounted; running command as www-data while the key is elsewhere; case-sensitive path mistakes.","solutions":["Generate the server key: sudo su -s /bin/bash -c './bin/cake passbolt create_gpg_server_key' www-data.","Check the configured path: 'bin/cake passbolt verify' or grep passbolt.gpg.serverKey.private in config/passbolt.php and correct it to the existing key file (default config/gpg/serverkey_private.asc).","Ensure the file is readable by the user running keyring init (chown/chmod, e.g. owned by www-data with mode 600).","Re-run 'bin/cake passbolt keyring init'."],"exampleFix":"// before (config/passbolt.php)\n'passbolt' => ['gpg' => ['serverKey' => ['private' => '/wrong/path/serverkey_private.asc']]],\n// after\n'passbolt' => ['gpg' => ['serverKey' => ['private' => CONFIG . 'gpg' . DS . 'serverkey_private.asc']]],","handlingStrategy":"validation","validationCode":"$path = Configure::read('passbolt.gpg.serverKey.private');\nif (empty($path) || !is_file($path)) {\n    fwrite(STDERR, \"Server private key missing: '{$path}'. Run create_gpg_server_key first.\\n\");\n    exit(1);\n}","typeGuard":null,"tryCatchPattern":"try {\n    $this->KeyringInitCommand->execute($args, $io);\n} catch (CakeException $e) {\n    if (str_starts_with($e->getMessage(), 'The file does not exist')) {\n        // generate or fix path of the server key, then retry\n    }\n}","preventionTips":["Run create_gpg_server_key before keyring init.","Verify passbolt.gpg.serverKey.private with 'bin/cake passbolt verify'.","In Docker, mount the key volume at the exact configured path.","Use absolute, case-correct paths in passbolt.php."],"tags":["cli","gpg","configuration","filesystem"],"backgroundTag":"file-not-found","analyzedSha":"31c1bbc10f32808a607fa9bd81891e898779c0bc","analyzedAt":"2026-09-17T00:04:38.960Z","contentChangedAt":"2026-09-17T00:04:38.960Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}