{"record":{"id":"c0472250a08bd014","repo":"passbolt/passbolt_api","slug":"if-you-are-using-composer-run","errorCode":null,"errorMessage":"If you are using composer run","messagePattern":"If you are using composer run","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/Command/ConsoleCommand.php","lineNumber":47,"sourceCode":" */\nclass ConsoleCommand extends Command\n{\n    /**\n     * Start the Command and interactive console.\n     *\n     * @param \\Cake\\Console\\Arguments $args The command arguments.\n     * @param \\Cake\\Console\\ConsoleIo $io The console io\n     * @return int|null|void The exit code or null for success\n     */\n    public function execute(Arguments $args, ConsoleIo $io) // phpcs:ignore\n    {\n        if (!class_exists('Psy\\Shell')) {\n            $io->err('<error>Unable to load Psy\\Shell.</error>');\n            $io->err('');\n            $io->err('Make sure you have installed psysh as a dependency,');\n            $io->err('and that Psy\\Shell is registered in your autoloader.');\n            $io->err('');\n            $io->err('If you are using composer run');\n            $io->err('');\n            $io->err('<info>$ php composer.phar require psy/psysh</info>');\n            $io->err('');\n\n            return static::CODE_ERROR;\n        }\n\n        $io->out('You can exit with <info>`CTRL-C`</info> or <info>`exit`</info>');\n        $io->out();\n\n        Log::drop('debug');\n        Log::drop('error');\n        $io->setLoggers(false);\n        restore_error_handler();\n        restore_exception_handler();\n\n        $psy = new PsyShell(new PsyConfiguration([\n            'updateCheck' => 'never',","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/src/Command/ConsoleCommand.php#L29-L65","documentation":"This is not an exception but a styled CLI error line printed by ConsoleCommand::execute() when the interactive console cannot start because the Psy\\Shell class (psy/psysh package) is not autoloadable. The library checks class_exists('Psy\\Shell') and, on failure, prints a multi-line diagnostic block guiding the developer to install psysh via composer. It exists to fail fast with actionable guidance instead of a fatal class-not-found error.","triggerScenarios":"Running the console command (bin/cake console) in an environment where the psy/psysh composer package is absent — e.g. a production deployment without dev dependencies, or composer install with --no-dev.","commonSituations":"Deploying passbolt to production where require-dev packages (psysh is typically a dev dependency) are skipped; running the shell inside a minimal Docker image; forgetting to run composer install after cloning; a broken vendor/ autoloader.","solutions":["Run composer to install psysh: composer require psy/psysh (or composer install if it is already in composer.json dev requirements).","If running in production, verify this is intentional — the console shell should usually not be used there; remove it from deployment scripts.","Check vendor/ exists and vendor/autoload.php includes the class: php -r \"var_dump(class_exists('Psy\\\\Shell'));\"","Clear composer autoload caches: composer dump-autoload."],"exampleFix":"// before (terminal)\n$ bin/cake console\nUnable to load Psy\\Shell.\n\n// after\n$ composer require --dev psy/psysh\n$ bin/cake console\nYou can exit with `CTRL-C` or `exit`","handlingStrategy":"validation","validationCode":"// shell script guard before invoking the console\nif php -r \"exit(class_exists('Psy\\\\Shell') ? 0 : 1);\"; then\n  bin/cake console\nelse\n  echo \"psysh missing; run: composer require psy/psysh\" >&2\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add psy/psysh to composer.json require-dev and always run composer install (not --no-dev) in dev/CI environments.","Add a pre-flight class_exists check to deployment scripts that invoke the console.","Keep vendor/ intact — never deploy a pruned autoloader to environments where you need the interactive shell."],"tags":["cli","composer","missing-dependency","console"],"backgroundTag":"missing-dependency","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"}