passbolt/passbolt_api · error

Unable to load Psy\Shell.</error>

Error message

<error>Unable to load Psy\Shell.</error>

What it means

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.

Solutions

  1. Install the dependency: composer require --dev psy/psysh (or non-dev if desired).
  2. If already in composer.json, run composer install and composer dump-autoload.
  3. Verify class availability: php -r "var_dump(class_exists('Psy\\Shell'));".

Example fix

// before
composer install --no-dev
// after
composer install  # or: composer require --dev psy/psysh
Defensive patterns

Strategy: fallback

Validate before calling

if (!class_exists('Psy\Shell')) {
    echo "psysh not installed; run: composer require --dev psy/psysh\n";
    exit(1);
}

Type guard

if (!class_exists('Psy\Shell')) { /* bail out before executing console */ }

Try / catch

if (!class_exists('Psy\Shell')) {
    $io->err('Unable to load Psy\Shell. Install with: composer require --dev psy/psysh');
    return static::CODE_ERROR;
}

Prevention

When it happens

Trigger: 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.

Common situations: Production deployments (composer install --no-dev), docker images without dev packages, or a composer autoload that was never dumped after adding psysh.

Understand the failure class

Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.

Related errors


AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17). Data as JSON: /api/errors/381e9d840de8d876. Report an issue: GitHub.

Appendix: source

Thrown at src/Command/ConsoleCommand.php:42

use Psy\Configuration as PsyConfiguration;
use Psy\Shell as PsyShell;

/**
 * Simple console wrapper around Psy\Shell.
 */
class ConsoleCommand extends Command
{
    /**
     * Start the Command and interactive console.
     *
     * @param \Cake\Console\Arguments $args The command arguments.
     * @param \Cake\Console\ConsoleIo $io The console io
     * @return int|null|void The exit code or null for success
     */
    public function execute(Arguments $args, ConsoleIo $io) // phpcs:ignore
    {
        if (!class_exists('Psy\Shell')) {
            $io->err('<error>Unable to load Psy\Shell.</error>');
            $io->err('');
            $io->err('Make sure you have installed psysh as a dependency,');
            $io->err('and that Psy\Shell is registered in your autoloader.');
            $io->err('');
            $io->err('If you are using composer run');
            $io->err('');
            $io->err('<info>$ php composer.phar require psy/psysh</info>');
            $io->err('');

            return static::CODE_ERROR;
        }

        $io->out('You can exit with <info>`CTRL-C`</info> or <info>`exit`</info>');
        $io->out();

        Log::drop('debug');
        Log::drop('error');
        $io->setLoggers(false);

View on GitHub (pinned to 31c1bbc10f)