drush
drush copied to clipboard
Globally installed Drush 11 (no Drupal) depends on symfony/http-kernel but does not require it
Describe the bug Fresh install of Composer
PHP 8.1.5 (cli) (built: Apr 16 2022 00:14:18) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.5, Copyright (c) Zend Technologies
with Zend OPcache v8.1.5, Copyright (c), by Zend Technologies
Composer version 2.3.6 2022-06-01 21:57:13
Checked several times - installing Drush 11 and then calling drush --version ends up with
Fatal error: Uncaught Error: Class "Symfony\Component\HttpKernel\Kernel" not found in /Users/____/.composer/vendor/drush/drush/src/Preflight/Preflight.php:208
Stack trace:
#0 /Users/____/.composer/vendor/drush/drush/src/Runtime/Runtime.php(84): Drush\Preflight\Preflight->loadSymfonyCompatabilityAutoloader()
#1 /Users/____/.composer/vendor/drush/drush/src/Runtime/Runtime.php(51): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput))
#2 /Users/____/.composer/vendor/drush/drush/drush.php(72): Drush\Runtime\Runtime->run(Array)
#3 /Users/____/.composer/vendor/drush/drush/drush(4): require('/Users/o_o/.com...')
#4 /Users/____/.composer/vendor/bin/drush(117): include('/Users/o_o/.com...')
#5 {main}
thrown in /Users/____/.composer/vendor/drush/drush/src/Preflight/Preflight.php on line 208
Checked dependencies - no deps on symfony/http-kernel in ccomposer.json but the deps was introduced in https://github.com/drush-ops/drush/pull/5108
https://github.com/drush-ops/drush/pull/5108/files#diff-fcb54a74a331c6112bd5cf5e32f08a4d0a39f42c16833b899b4fac0339d453c7R204
There are no other packages installed globally - only drush 11.
{
"require": {
"drush/drush": "^11.0"
}
}
To Reproduce
composer global install drush/drush
drush --version
Expected behavior Drush to print version
Actual behavior
Fatal error: Uncaught Error: Class "Symfony\Component\HttpKernel\Kernel" not found in /Users/____/.composer/vendor/drush/drush/src/Preflight/Preflight.php:208
Stack trace:
#0 /Users/____/.composer/vendor/drush/drush/src/Runtime/Runtime.php(84): Drush\Preflight\Preflight->loadSymfonyCompatabilityAutoloader()
#1 /Users/____/.composer/vendor/drush/drush/src/Runtime/Runtime.php(51): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput))
#2 /Users/____/.composer/vendor/drush/drush/drush.php(72): Drush\Runtime\Runtime->run(Array)
#3 /Users/____/.composer/vendor/drush/drush/drush(4): require('/Users/o_o/.com...')
#4 /Users/____/.composer/vendor/bin/drush(117): include('/Users/o_o/.com...')
#5 {main}
thrown in /Users/____/.composer/vendor/drush/drush/src/Preflight/Preflight.php on line 208
Workaround
Explicitly install symfony/http-kernel globally
System Configuration
| Q | A |
|---|---|
| Drush version? | 11.0.9 |
| Drupal version? | NONE |
| PHP version | 8.1 |
| OS? | Mac/Linux |
Additional information
Attaching "pure"composer.lock - no deps on symfony/http-kernel declared and the package itself is not present.
Looking at CI config - there are only jobs with Drupal installed - there is no build of the standalone installation. Maybe it can be added to make sure that Drush can be installed without relying on Drupal's dependencies.
I'm not sure that dependency is deliberate. Might be change that check to survive that package being missing. ping @greg-1-anderson
Yeah, the reference was added here:
https://github.com/drush-ops/drush/pull/5108/files#diff-fcb54a74a331c6112bd5cf5e32f08a4d0a39f42c16833b899b4fac0339d453c7R204
Wasn't caught because a global install of Drush 11 is not a recommended configuration. Adding a direct dependency on symfony/http-kernel is reasonable, though.
A global install of Drush 11 is only going to work with Drupal 9 anyway, so I suppose we could simply assume 6 if symfony/http-kernel does not exist. I think simply adding the dependency is probably more straightforward, though.
I would prefer that over a new dependency. We dont speak http and I dont want anyone to get ideas that we should.
I wonder if the Symfony major version exists in some other Symfony project.
Can we please at least add some check for class existence or some other gate to prevent this.
Drush is installed on many systems as global and a version check is a simplest test that a package works. Currently, this fails, which breaks automations.
Even installing it as local without any other packages will lead to the same error when calling drush --version.
Thank you for looking into this in a such short notice.
PRs welcome. I may eventually have time to take this on.
As an aside, although global installs of Drush are not recommended in general, composer global require in particular is deprecated. See Fixing the Composer Global Command.
For anyone encountering this bug. Do this:
composer require symfony/http-kernel -W
composer require symfony/http-kernel -W did not work for me. I got this:
Using version ^5.4 for symfony/http-kernel ./composer.json has been updated Running composer update symfony/http-kernel --with-all-dependencies Loading composer repositories with package information Updating dependencies Your requirements could not be resolved to an installable set of packages.
Problem 1 - Root composer.json requires symfony/http-kernel ^5.4, found symfony/http-kernel[v5.4.0-BETA1, ..., 5.4.x-dev] but these were not loaded, likely because it conflicts with another require. Problem 2 - drupal/core-recommended is locked to version 9.5.0-beta2 and an update of this package was not requested. - drupal/core-recommended 9.5.0-beta2 requires symfony/http-kernel ~v4.4.45 -> found symfony/http-kernel[v4.4.45, ..., 4.4.x-dev] but it conflicts with your root composer.json require (^5.4). Problem 3 - drupal/core 9.5.0-beta2 requires symfony/http-kernel ^4.4 -> found symfony/http-kernel[v4.4.0-BETA1, ..., 4.4.x-dev] but it conflicts with your root composer.json require (^5.4). - drupal/semver_example 2.3.0 requires drupal/core >=8 -> satisfiable by drupal/core[9.5.0-beta2]. - drupal/semver_example is locked to version 2.3.0 and an update of this package was not requested.
You can also try re-running composer require with an explicit version constraint, e.g. "composer require symfony/http-kernel:*" to figure out if any version is installable, or "composer require symfony/http-kernel:^2.1" if you know which you need.
Installation failed, reverting ./composer.json and ./composer.lock to their original content. [vps25749]$ composer require symfony/http-kernel:* ./composer.json has been updated Running composer update symfony/http-kernel Loading composer repositories with package information Updating dependencies Your requirements could not be resolved to an installable set of packages.
Problem 1 - drush/drush is present at version 1.0.0+no-version-set and cannot be modified by Composer - drupal/core-recommended 9.5.0-beta2 requires drupal/core 9.5.0-beta2 -> satisfiable by drupal/core[9.5.0-beta2]. - drupal/core 9.5.0-beta2 conflicts with drush/drush <8.1.10. - drupal/core-recommended is locked to version 9.5.0-beta2 and an update of this package was not requested.
Installation failed, reverting ./composer.json and ./composer.lock to their original content.
composer require symfony/http-kernel -W did not work for me. I got this:
Using version ^5.4 for symfony/http-kernel ./composer.json has been updated Running composer update symfony/http-kernel --with-all-dependencies Loading composer repositories with package information Updating dependencies Your requirements could not be resolved to an installable set of packages.
Problem 1 - Root composer.json requires symfony/http-kernel ^5.4, found symfony/http-kernel[v5.4.0-BETA1, ..., 5.4.x-dev] but these were not loaded, likely because it conflicts with another require. Problem 2 - drupal/core-recommended is locked to version 9.5.0-beta2 and an update of this package was not requested. - drupal/core-recommended 9.5.0-beta2 requires symfony/http-kernel ~v4.4.45 -> found symfony/http-kernel[v4.4.45, ..., 4.4.x-dev] but it conflicts with your root composer.json require (^5.4). Problem 3 - drupal/core 9.5.0-beta2 requires symfony/http-kernel ^4.4 -> found symfony/http-kernel[v4.4.0-BETA1, ..., 4.4.x-dev] but it conflicts with your root composer.json require (^5.4). - drupal/semver_example 2.3.0 requires drupal/core >=8 -> satisfiable by drupal/core[9.5.0-beta2]. - drupal/semver_example is locked to version 2.3.0 and an update of this package was not requested.
You can also try re-running composer require with an explicit version constraint, e.g. "composer require symfony/http-kernel:*" to figure out if any version is installable, or "composer require symfony/http-kernel:^2.1" if you know which you need.
Installation failed, reverting ./composer.json and ./composer.lock to their original content. [vps25749]$ composer require symfony/http-kernel:* ./composer.json has been updated Running composer update symfony/http-kernel Loading composer repositories with package information Updating dependencies Your requirements could not be resolved to an installable set of packages.
Problem 1 - drush/drush is present at version 1.0.0+no-version-set and cannot be modified by Composer - drupal/core-recommended 9.5.0-beta2 requires drupal/core 9.5.0-beta2 -> satisfiable by drupal/core[9.5.0-beta2]. - drupal/core 9.5.0-beta2 conflicts with drush/drush <8.1.10. - drupal/core-recommended is locked to version 9.5.0-beta2 and an update of this package was not requested.
Installation failed, reverting ./composer.json and ./composer.lock to their original content.
¿Do you fix that issue? I have the same problem
I have not (yet) fixed the issue. (Disclaimer - I'm in a bit over my head and trying to understand explanations and suggestions from various support sources, so take my thoughts with several grains of salt.)
I was told it is better practice to install Composer globally but Drush locally in each project, and use drush-launcher to call/access the drush version that is appropriate for the given project.
https://github.com/drush-ops/drush-launcher
I installed Composer globally on my BPS without issue and then hit a brick wall with Drush. It seemed to install but wold not init. I've been told now to use drush-launcher but I am not sure whether or not to leave the drush I installed globally but could not init, and exactly what the work flow will be once I move my shared hosting projects into the VPS. I think I am supposed to - in EACH project - do composer require drush/drush and then use drush launcher to launch that version's drush.
For anyone encountering this bug. Do this:
composer require symfony/http-kernel -W
I think what you meant was
composer global require symfony/http-kernel -W
Please do not use composer global require. See https://github.com/drush-ops/drush/issues/5156#issuecomment-1146380239.
composer require symfony/http-kernel -W resolves the issue if drush is not globally installed by composer require drush/drush.
A dependency of Symfony is needed for drush, if drush is not installed along with Drupal.
FYI this constant is not in Drush 12 anymore (not yet released). We can keep this issue open for prior versions.
C:\xampp\htdocs\silkmark-pressflow>drush updatedb [preflight] Package "drupal/core" is not installed
How to fix this