error during running drush for drupal 9.4.8 on docker linux

1k Views Asked by At

am trying to run a drupal project using drush on linux docker ,this is a backend project we use json api to connect to frontend nextjs. once i use any drush comman it give me this error :

[warning] include_once(/var/www/html/docroot/modules/contrib/rest_menu_items/rest_menu_items.module): failed to open stream: No such file or directory Extension.php:147
 [warning] include_once(): Failed opening '/var/www/html/docroot/modules/contrib/rest_menu_items/rest_menu_items.module' for inclusion (include_path='/var/www/html/vendor/pear/archive_tar:/var/www/html/vendor/pear/console_getopt:/var/www/html/vendor/pear/pear-core-minimal/src:/var/www/html/vendor/pear/pear_exception:.:/usr/local/lib/php') Extension.php:147
 [error]  ArgumentCountError: Too few arguments to function Drush\Drupal\Commands\config\ConfigExportCommands::__construct(), 2 passed in /var/www/html/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php on line 262 and exactly 3 expected in Drush\Drupal\Commands\config\ConfigExportCommands->__construct() (line 86 of /var/www/html/vendor/drush/drush/src/Drupal/Commands/config/ConfigExportCommands.php) #0 /var/www/html/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(262): Drush\Drupal\Commands\config\ConfigExportCommands->__construct(Object(Drupal\Core\Config\ConfigManager), Object(Drupal\Core\Config\CachedStorage))
#1 /var/www/html/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(176): Drupal\Component\DependencyInjection\Container->createService(Array, 'config.export.c...')
#2 /var/www/html/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(437): Drupal\Component\DependencyInjection\Container->get('config.export.c...', 3)
#3 /var/www/html/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(276): Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array)
#4 /var/www/html/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(176): Drupal\Component\DependencyInjection\Container->createService(Array, 'drush.command.s...')
#5 /var/www/html/vendor/drush/drush/src/Boot/DrupalBoot8.php(280): Drupal\Component\DependencyInjection\Container->get('drush.command.s...')
#6 /var/www/html/vendor/drush/drush/src/Boot/DrupalBoot8.php(246): Drush\Boot\DrupalBoot8->addDrupalModuleDrushCommands(Object(Drush\Boot\BootstrapManager))
#7 /var/www/html/vendor/drush/drush/src/Boot/BootstrapManager.php(293): Drush\Boot\DrupalBoot8->bootstrapDrupalFull(Object(Drush\Boot\BootstrapManager), NULL)
#8 /var/www/html/vendor/drush/drush/src/Boot/BootstrapManager.php(493): Drush\Boot\BootstrapManager->doBootstrap(5, 6, NULL)
#9 /var/www/html/vendor/drush/drush/src/Boot/BootstrapManager.php(427): Drush\Boot\BootstrapManager->bootstrapMax(6)
#10 /var/www/html/vendor/drush/drush/src/Boot/BootstrapManager.php(396): Drush\Boot\BootstrapManager->bootstrapToPhaseIndex(-2, Object(Consolidation\AnnotatedCommand\AnnotationData))
#11 /var/www/html/vendor/drush/drush/src/Boot/BootstrapHook.php(28): Drush\Boot\BootstrapManager->bootstrapToPhase('max', Object(Consolidation\AnnotatedCommand\AnnotationData))
#12 /var/www/html/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php(44): Drush\Boot\BootstrapHook->initialize(Object(Drush\Symfony\DrushArgvInput), Object(Consolidation\AnnotatedCommand\AnnotationData))
#13 /var/www/html/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php(36): Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->doInitializeHook(Object(Drush\Boot\BootstrapHook), Object(Drush\Symfony\DrushArgvInput), Object(Consolidation\AnnotatedCommand\AnnotationData))
#14 /var/www/html/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php(29): Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->callInitializeHook(Object(Drush\Boot\BootstrapHook), Object(Drush\Symfony\DrushArgvInput), Object(Consolidation\AnnotatedCommand\AnnotationData))
#15 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(145): Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->initialize(Object(Drush\Symfony\DrushArgvInput), Object(Consolidation\AnnotatedCommand\AnnotationData))
#16 /var/www/html/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(375): Consolidation\AnnotatedCommand\CommandProcessor->initializeHook(Object(Drush\Symfony\DrushArgvInput), Array, Object(Consolidation\AnnotatedCommand\AnnotationData))
#17 /var/www/html/vendor/symfony/console/Command/Command.php(221): Consolidation\AnnotatedCommand\AnnotatedCommand->initialize(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 /var/www/html/vendor/symfony/console/Application.php(1039): Symfony\Component\Console\Command\Command->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 /var/www/html/vendor/symfony/console/Application.php(275): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 /var/www/html/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#21 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(118): Symfony\Component\Console\Application->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#22 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(48): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput))
#23 /var/www/html/vendor/drush/drush/drush.php(72): Drush\Runtime\Runtime->run(Array)
#24 /var/www/html/vendor/drush/drush/drush(4): require('/var/www/html/v...')
#25 {main}.
ArgumentCountError: Too few arguments to function Drush\Drupal\Commands\config\ConfigExportCommands::__construct(), 2 passed in /var/www/html/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php on line 262 and exactly 3 expected in /var/www/html/vendor/drush/drush/src/Drupal/Commands/config/ConfigExportCommands.php on line 86 #0 /var/www/html/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(262): Drush\Drupal\Commands\config\ConfigExportCommands->__construct(Object(Drupal\Core\Config\ConfigManager), Object(Drupal\Core\Config\CachedStorage))
#1 /var/www/html/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(176): Drupal\Component\DependencyInjection\Container->createService(Array, 'config.export.c...')
#2 /var/www/html/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(437): Drupal\Component\DependencyInjection\Container->get('config.export.c...', 3)
#3 /var/www/html/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(276): Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array)
#4 /var/www/html/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(176): Drupal\Component\DependencyInjection\Container->createService(Array, 'drush.command.s...')
#5 /var/www/html/vendor/drush/drush/src/Boot/DrupalBoot8.php(280): Drupal\Component\DependencyInjection\Container->get('drush.command.s...')
#6 /var/www/html/vendor/drush/drush/src/Boot/DrupalBoot8.php(246): Drush\Boot\DrupalBoot8->addDrupalModuleDrushCommands(Object(Drush\Boot\BootstrapManager))
#7 /var/www/html/vendor/drush/drush/src/Boot/BootstrapManager.php(293): Drush\Boot\DrupalBoot8->bootstrapDrupalFull(Object(Drush\Boot\BootstrapManager), NULL)
#8 /var/www/html/vendor/drush/drush/src/Boot/BootstrapManager.php(493): Drush\Boot\BootstrapManager->doBootstrap(5, 6, NULL)
#9 /var/www/html/vendor/drush/drush/src/Boot/BootstrapManager.php(427): Drush\Boot\BootstrapManager->bootstrapMax(6)
#10 /var/www/html/vendor/drush/drush/src/Boot/BootstrapManager.php(396): Drush\Boot\BootstrapManager->bootstrapToPhaseIndex(-2, Object(Consolidation\AnnotatedCommand\AnnotationData))
#11 /var/www/html/vendor/drush/drush/src/Boot/BootstrapHook.php(28): Drush\Boot\BootstrapManager->bootstrapToPhase('max', Object(Consolidation\AnnotatedCommand\AnnotationData))
#12 /var/www/html/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php(44): Drush\Boot\BootstrapHook->initialize(Object(Drush\Symfony\DrushArgvInput), Object(Consolidation\AnnotatedCommand\AnnotationData))
#13 /var/www/html/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php(36): Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->doInitializeHook(Object(Drush\Boot\BootstrapHook), Object(Drush\Symfony\DrushArgvInput), Object(Consolidation\AnnotatedCommand\AnnotationData))
#14 /var/www/html/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php(29): Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->callInitializeHook(Object(Drush\Boot\BootstrapHook), Object(Drush\Symfony\DrushArgvInput), Object(Consolidation\AnnotatedCommand\AnnotationData))
#15 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(145): Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->initialize(Object(Drush\Symfony\DrushArgvInput), Object(Consolidation\AnnotatedCommand\AnnotationData))
#16 /var/www/html/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(375): Consolidation\AnnotatedCommand\CommandProcessor->initializeHook(Object(Drush\Symfony\DrushArgvInput), Array, Object(Consolidation\AnnotatedCommand\AnnotationData))
#17 /var/www/html/vendor/symfony/console/Command/Command.php(221): Consolidation\AnnotatedCommand\AnnotatedCommand->initialize(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 /var/www/html/vendor/symfony/console/Application.php(1039): Symfony\Component\Console\Command\Command->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 /var/www/html/vendor/symfony/console/Application.php(275): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 /var/www/html/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#21 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(118): Symfony\Component\Console\Application->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#22 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(48): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput))
#23 /var/www/html/vendor/drush/drush/drush.php(72): Drush\Runtime\Runtime->run(Array)
#24 /var/www/html/vendor/drush/drush/drush(4): require('/var/www/html/v...')
#25 {main}
ArgumentCountError: Too few arguments to function Drush\Drupal\Commands\config\ConfigExportCommands::__construct(), 2 passed in /var/www/html/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php on line 262 and exactly 3 expected in Drush\Drupal\Commands\config\ConfigExportCommands->__construct() (line 86 of /var/www/html/vendor/drush/drush/src/Drupal/Commands/config/ConfigExportCommands.php).
 [warning] Drush command terminated abnormally.

this is composer.json file:

"name": "drupal",
    "description": "Project for Drupal 9 projects with a relocated document root",
    "type": "project",
    "license": "GPL-2.0-or-later",
    "homepage": "https://www.drupal.org/project/drupal",
    "support": {
        "docs": "https://www.drupal.org/docs/user_guide/en/index.html",
        "chat": "https://www.drupal.org/node/314178"
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        }
    ],
    "require": {
        "composer/installers": "^1.9",
        "cweagans/composer-patches": "^1.7",
        "drupal/acquia_connector": "^4.0",
        "drupal/acquia_search": "^3.1",
        "drupal/admin_toolbar": "^3.2.0",
        "drupal/adminimal_theme": "^1.4",
        "drupal/config_split": "^1.7",
        "drupal/core": "^9.4",
        "drupal/core-composer-scaffold": "^9.4.8",
        "drupal/core-project-message": "^9.4.8",
        "drupal/core-recommended": "^9.4.8",
        "drupal/decoupled_router": "^2.0",
        "drupal/editor_advanced_link": "^1.8",
        "drupal/field_group": "^3.1",
        "drupal/health_check": "^1.3",
        "drupal/improve_line_breaks_filter": "^1.3",
        "drupal/jsonapi_extras": "^3.16",
        "drupal/jsonapi_search_api": "^1.0@RC",
        "drupal/link_attributes": "^1.11",
        "drupal/link_field_autocomplete_filter": "^1.14",
        "drupal/linkit": "^5.0@beta",
        "drupal/menu_link_attributes": "^1.2",
        "drupal/metatag": "^1.15",
        "drupal/miniorange_saml": "^2.21",
        "drupal/mysql56": "^1.0@beta",
        "drupal/onlyone": "^1.10",
        "drupal/openid_connect": "^1.0",
        "drupal/paragraphs": "^1.12",
        "drupal/pathauto": "^1.8",
        "drupal/redirect": "^1.7",
        "drupal/rest_menu_items": "^3.0",
        "drupal/restui": "^1.21",
        "drupal/scheduler": "^1.3",
        "drupal/search_api": "^1.19",
        "drupal/search_api_solr": "^4.1",
        "drupal/simple_menu_icons": "^2.2",
        "drupal/subrequests": "^3.0",
        "drupal/svg_image": "^1.14",
        "drupal/url_redirect": "^2.62",
        "drush/drush": "~10"
    },
    "require-dev": {
        "drupal/core-dev": "^9.4.8"
    },
    "conflict": {
        "drupal/drupal": "*"
    },
    "minimum-stability": "beta",
    "prefer-stable": true,
    "config": {
        "sort-packages": true,
        "allow-plugins": {
            "composer/installers": true,
            "dealerdirect/phpcodesniffer-composer-installer": true,
            "cweagans/composer-patches": true,
            "drupal/core-composer-scaffold": true,
            "drupal/core-project-message": true
        }
    },
    "extra": {
        "drupal-scaffold": {
            "locations": {
                "web-root": "docroot/"
            }
        },
        "installer-paths": {
            "docroot/core": [
                "type:drupal-core"
            ],
            "docroot/libraries/{$name}": [
                "type:drupal-library"
            ],
            "docroot/modules/contrib/{$name}": [
                "type:drupal-module"
            ],
            "docroot/profiles/contrib/{$name}": [
                "type:drupal-profile"
            ],
            "docroot/themes/contrib/{$name}": [
                "type:drupal-theme"
            ],
            "drush/Commands/contrib/{$name}": [
                "type:drupal-drush"
            ],
            "docroot/modules/custom/{$name}": [
                "type:drupal-custom-module"
            ],
            "docroot/profiles/custom/{$name}": [
                "type:drupal-custom-profile"
            ],
            "docroot/themes/custom/{$name}": [
                "type:drupal-custom-theme"
            ]
        },
        "drupal-core-project-message": {
            "include-keys": [
                "homepage",
                "support"
            ],
            "post-create-project-cmd-message": [
                "<bg=blue;fg=white>                                                         </>",
                "<bg=blue;fg=white>  Congratulations, you’ve installed the Drupal codebase  </>",
                "<bg=blue;fg=white>  from the drupal/recommended-project template!          </>",
                "<bg=blue;fg=white>                                                         </>",
                "",
                "<bg=yellow;fg=black>Next steps</>:",
                "  * Install the site: https://www.drupal.org/docs/8/install",
                "  * Read the user guide: https://www.drupal.org/docs/user_guide/en/index.html",
                "  * Get support: https://www.drupal.org/support",
                "  * Get involved with the Drupal community:",
                "      https://www.drupal.org/getting-involved",
                "  * Remove the plugin that prints this message:",
                "      composer remove drupal/core-project-message"
            ]
        },
        "patches": {
            "drupal/subrequests": {
                "Fix issue which give same result for multiple subrequests": "https://www.drupal.org/files/issues/2019-07-18/change_request_type-63049395-09.patch",
                "JSON validator issue": "https://www.drupal.org/files/issues/2019-05-27/3029570-array-not-object.patch",
                "Fix the no candidate token replacement": "patches/token-replacement-issue.patch.txt"
            },
            "drupal/metatag": {
                "Expose metatag through JSON:API": "https://www.drupal.org/files/issues/2020-02-29/2945817-93.patch"
            }
        }
    }
}

this project is hosted on acquia hosting , online the project run but we have error on login :

"Drupal\acquia_connector\AuthService" not found in /mnt/www/html/website/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php on line 262 #0 /mnt/www/html/website/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(176): Drupal\Component\DependencyInjection\Container->createService(Array, 'acquia_connecto...') #1

1

There are 1 best solutions below

0
Vlad Moyseenko On

Despite the fact I got the same warnings and messages but in a different scenario using Drush, I think the fix for the author's problem and mine is the same.

Acquia uses some magic to bootstrap site-specific settings.php files. I think you are running drush on Acquia Cloud Platform. Acquia added notice that it is better to specify all args for drush command in the next way:

drush --root=/var/www/html/[application].[env]/docroot

But this is half of the deal) By default, Acquia environmental variables should be set automatically on shell login event. Here are some of them (most critical): AH_SITE_GROUP, AH_SITE_ENVIRONMENT.

It seems for some reason in your and my cases they weren't set. The "Drupal\acquia_connector\AuthService" not found in /mnt/www/html/website/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php log gives a tip that your project named as website and probably you aren't using dev/test/prod env.

And log entry include_once(/var/www/html/docroot/modules/contrib/rest_menu_items) confirms my suggestion that AH_SITE_GROUP hasn't picked up because then the path should be: /var/www/html/website/docroot/modules/contrib/rest_menu_items

Could you try to run drush command?

export AH_SITE_GROUP=website;/var/www/html/website/vendor/bin/drush --root=/var/www/html/website/docroot st

Note: if you are using dev/test/prod then export also AH_SITE_ENVIRONMENT variable too.

I advise you to ask Acquia support where to configure these magic variables in order to load them automatically for Drush. Alternatively, you can add such kind of alias to run drush into .bash_aliases file.

Probably you might need to export also HOME variable: export HOME=/var/www/html/website


My case was a bit different - spawning drush command from a shell script that is running in background mode by form submit custom module's function.

More details about my case here: https://gist.github.com/vladdancer/4c8ea46d2b63eb4fd89d5e51315e931a

I also want to cross-post https://www.drupal.org/project/config_ignore/issues/3197355 issue because it has a very similar debug output:

TypeError: Argument 4 passed to Drush\Drupal\Commands\config\ConfigImportCommands::__construct() must implement interface Drupal\Core\Cache\CacheBackendInterface

But both of them have nothing to the actual ConfigImport command. So leaving crosslinks here to help people find this solution.

Let me know if the suggested solution worked for you!