{"record":{"id":"381e9d840de8d876","repo":"passbolt/passbolt_api","slug":"error-unable-to-load-psy-shell-error","errorCode":null,"errorMessage":"<error>Unable to load Psy\\Shell.</error>","messagePattern":"<error>Unable to load Psy\\\\Shell\\.</error>","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/Command/ConsoleCommand.php","lineNumber":42,"sourceCode":"use Psy\\Configuration as PsyConfiguration;\nuse Psy\\Shell as PsyShell;\n\n/**\n * Simple console wrapper around Psy\\Shell.\n */\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);","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/src/Command/ConsoleCommand.php#L24-L60","documentation":"ConsoleCommand (`bin/cake passbolt console`) opens an interactive REPL using psy/psysh. If the Psy\\Shell class is not autoloadable, the command prints '<error>Unable to load Psy\\Shell.</error>' and installation instructions instead of starting the shell. This indicates the psysh package is not installed in the running codebase.","triggerScenarios":"Running `bin/cake passbolt console` in an environment where psy/psysh was never composer-installed, or was installed as dev dependency but dependencies were installed with --no-dev in production.","commonSituations":"Production deployments (composer install --no-dev), docker images without dev packages, or a composer autoload that was never dumped after adding psysh.","solutions":["Install the dependency: composer require --dev psy/psysh (or non-dev if desired).","If already in composer.json, run composer install and composer dump-autoload.","Verify class availability: php -r \"var_dump(class_exists('Psy\\\\Shell'));\"."],"exampleFix":"// before\ncomposer install --no-dev\n// after\ncomposer install  # or: composer require --dev psy/psysh","handlingStrategy":"fallback","validationCode":"if (!class_exists('Psy\\Shell')) {\n    echo \"psysh not installed; run: composer require --dev psy/psysh\\n\";\n    exit(1);\n}","typeGuard":"if (!class_exists('Psy\\Shell')) { /* bail out before executing console */ }","tryCatchPattern":"if (!class_exists('Psy\\Shell')) {\n    $io->err('Unable to load Psy\\Shell. Install with: composer require --dev psy/psysh');\n    return static::CODE_ERROR;\n}","preventionTips":["Include psy/psysh in the environments where developers use the console","Avoid composer install --no-dev in development containers","Run composer dump-autoload after dependency changes"],"tags":["cli","console","php","missing-package"],"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"}