passbolt/passbolt_api · error · CakeException
The file does not exist
Error message
The file does not exist: {0} What it means
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.
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'.
Example fix
// before (config/passbolt.php) 'passbolt' => ['gpg' => ['serverKey' => ['private' => '/wrong/path/serverkey_private.asc']]], // after 'passbolt' => ['gpg' => ['serverKey' => ['private' => CONFIG . 'gpg' . DS . 'serverkey_private.asc']]],
Defensive patterns
Strategy: validation
Validate before calling
$path = Configure::read('passbolt.gpg.serverKey.private');
if (empty($path) || !is_file($path)) {
fwrite(STDERR, "Server private key missing: '{$path}'. Run create_gpg_server_key first.\n");
exit(1);
} Try / catch
try {
$this->KeyringInitCommand->execute($args, $io);
} catch (CakeException $e) {
if (str_starts_with($e->getMessage(), 'The file does not exist')) {
// generate or fix path of the server key, then retry
}
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- Could not read the file
- 500
- [FAIL] </error>
- $healthcheckService->getFailureMessage()
- Missing metadata private key.
AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17).
Data as JSON: /api/errors/f7f7c495c8b9bb5c.
Report an issue: GitHub.
Appendix: source
Thrown at src/Command/KeyringInitCommand.php:64
public static function getCommandDescription(): string
{
return __('GnuPG Keyring init shell for the passbolt application.');
}
/**
* @inheritDoc
*/
public function execute(Arguments $args, ConsoleIo $io): ?int
{
parent::execute($args, $io);
// Root user is not allowed to execute this command.
$this->assertCurrentProcessUser($io, $this->processUserService);
try {
$filePath = Configure::read('passbolt.gpg.serverKey.private');
if (!file_exists($filePath)) {
throw new CakeException(__('The file does not exist: {0}', $filePath));
}
$armoredKey = file_get_contents($filePath);
if ($armoredKey === false) {
throw new CakeException(__('Could not read the file: {0}', $filePath));
}
// Import the private key in the OpenPGP keyring
$gpg = OpenPGPBackendFactory::get();
$io->out('Importing ' . $filePath);
$gpg->importKeyIntoKeyring($armoredKey);
} catch (CakeException $e) {
$this->error($e->getMessage(), $io);
$this->error('Could not import the server OpenPGP key into the keyring.', $io);
return $this->errorCode();
}
$this->success('Keyring init OK', $io);View on GitHub (pinned to 31c1bbc10f)