I have been working on a Laravel 7 project since a while. Suddenly, my composer install returns the following error
Generating optimized autoload files
Class Modules\Tests\ThumbnailTest located in ./Modules/Media/Tests/ThumbnailTest.php does not comply with psr-4 autoloading standard. Skipping.
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
An option shortcut cannot be empty.
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
Laravel version: 7.2 php 7.2 OS: Ubuntu
I have made thousands of installs, and now this error is holding up my project.
The below is stack trace of the error
[2024-02-01 08:39:00] local.ERROR: An option shortcut cannot be empty. {"exception":"[object] (Symfony\\Component\\Console\\Exception\\InvalidArgumentException(code: 0): An option shortcut cannot be empty. at /home/myproject/vendor/symfony/console/Input/InputOption.php:85)
[stacktrace]
#0 /home/myproject/vendor/symfony/console/Command/Command.php(459): Symfony\\Component\\Console\\Input\\InputOption->__construct()
#1 /home/myproject/vendor/laravel/framework/src/Illuminate/Console/Concerns/HasParameters.php(32): Symfony\\Component\\Console\\Command\\Command->addOption()
#2 /home/myproject/vendor/laravel/framework/src/Illuminate/Console/Command.php(85): Illuminate\\Console\\Command->specifyParameters()
#3 [internal function]: Illuminate\\Console\\Command->__construct()
#4 /home/myproject/vendor/laravel/framework/src/Illuminate/Container/Container.php(849): ReflectionClass->newInstanceArgs()
#5 /home/myproject/vendor/laravel/framework/src/Illuminate/Container/Container.php(691): Illuminate\\Container\\Container->build()
#6 /home/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(796): Illuminate\\Container\\Container->resolve()
#7 /home/myproject/vendor/laravel/framework/src/Illuminate/Container/Container.php(637): Illuminate\\Foundation\\Application->resolve()
#8 /home/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(781): Illuminate\\Container\\Container->make()
#9 /home/myproject/vendor/laravel/framework/src/Illuminate/Console/Application.php(261): Illuminate\\Foundation\\Application->make()
#10 /home/myproject/vendor/laravel/framework/src/Illuminate/Console/Application.php(275): Illuminate\\Console\\Application->resolve()
#11 /home/myproject/vendor/laravel/framework/src/Illuminate/Support/ServiceProvider.php(333): Illuminate\\Console\\Application->resolveCommands()
#12 /home/myproject/vendor/laravel/framework/src/Illuminate/Console/Application.php(152): Illuminate\\Support\\ServiceProvider->Illuminate\\Support\\{closure}()
#13 /home/myproject/vendor/laravel/framework/src/Illuminate/Console/Application.php(75): Illuminate\\Console\\Application->bootstrap()
#14 /home/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(330): Illuminate\\Console\\Application->__construct()
#15 /home/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): Illuminate\\Foundation\\Console\\Kernel->getArtisan()
#16 /home/myproject/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle()
#17 {main}
"}
All my artisan commands return the same error: "An option shortcut cannot be empty"
Recently, I upgraded to Laravel 7. I have followed the upgrade guide. But this error stack is not giving me any hint where the problem lies.
Since this happens because of a change in the latest release of symfony/console, and a new version that reverts this change should be released shortly (but not immediately), you can simply tell composer to avoid installing this particular version.
In this case, add the following to your composer.json:
"conflict": {
"symfony/console": "5.4.35"
}
(If you already have a conflict key in there, just add the symfony/console line).
With this, this specific version of the library will be skipped on update/install commands.
(Also, to be noted, the only way for this to become a breaking change is for one to update an existing project, or create a project from scratch; installing an existing project should result on reading the lockfile, which should have the previously installed, working version).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With