How to use the filter flag in drush config:status

I am using Drush 10.3.6.

Drush config:status gives me:

# drush config:status
 --------------------------------- ------------ 
  Name                              State       
 --------------------------------- ------------ 
  webform.settings                  Different   
  webform.webform.contact           Only in DB  
  webform.webform.example_webform   Only in DB  
 --------------------------------- ------------ 

I am interested in filtering this to display only certain items, however the filter parameter does not work as expected:

# drush help config:status|grep Filter
  --filter[=FILTER] Filter output based on provided expression    

# drush --filter='^webform.webform..*$' config:status
In OperatorFactory.php line 50:
  Could not parse expression ^webform.webform..*$  

# drush --filter='webform.webform.*' config:status
In OperatorFactory.php line 50:
  Could not parse expression webform.webform.*  

What is format of the expression that needs to be passed to the filter parameter?

drush – What does this Composer error mean when I try to update my drupal core project?

I’ve installed my Drupal 9 site with the drupal/core-recommended composer project and was not having any issues until recently. Every time I try to update core with the following command (Which I’m getting from the official documentation), I get an error.

composer update drupal/core 'drupal/core-*' --with-all-dependencies

Console Error

Anyone know how I can get around this and update what is needed to get my site back on track? I’ve tried numerous things that either error out or don’t work + searched online but haven’t found anything that is of use to me.

Using drush config import and update db in a rolling deployment (k8s) environment

Disclaimer: complete Drupal newbie here. I’m the infrastructure guy in the team.

We are running various Drupal 8.9 instances on Kubernetes using a managed MariaDB outside k8s.

We build Docker containers for each instance on a build server using composer. Then, once deployed, a script initializes Drupal using a combination of drush cim, drush cr, drush updb and a few conditionals.

Kubernetes provides a rolling deployment so the current instance keeps running until the new container is up.
Now here’s the issue I can’t wrap my head around: the new and old instance both write to the same database. So drush cim from the new instance runs against the same DB as the live environment, possibly breaking the live instance.

I’m currently trying to catch this in my init script, but it proves to be non trivial. Ideas I came up with like cloning the db, doing the import there, testing if it works and then reimporting on the live instance appear overly complicated, Right now I do a dump before the drush cim so I can at least restore the instance if it fails but the site might still go down for a few minutes … is there a Drupal way of doing this properly? Maybe a config import dry run or forcing drush cim to use a SQL transaction? Do you guys have any idas or input? Anything helps. Thank you!

How do I generate taxonomy terms with drush 10/drupal 9.1.x

I’m trying to use drush to generate some taxonomy terms for a sandbox/development instance. This might be an error report by I’m a drush noob so I wanted to ask first.

When I run drush devel-generate:terms --bundles=tags 10 I would expect drush to generate some terms for me, instead I get an error message like this:

#10 0.555  (error)  TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in count() (line 377 of /opt/drupal/web/modules/contrib/devel/devel_generate/src/Plugin/DevelGenerate/TermDevelGenerate.php) #0 /opt/drupal/web/modules/contrib/devel/devel_generate/src/Plugin/DevelGenerate/TermDevelGenerate.php(377): count(NULL)
#10 0.555 #1 /opt/drupal/web/modules/contrib/devel/devel_generate/src/Plugin/DevelGenerate/TermDevelGenerate.php(197): Drupaldevel_generatePluginDevelGenerateTermDevelGenerate->generateTerms(Array)
#10 0.555 #2 /opt/drupal/web/modules/contrib/devel/devel_generate/src/DevelGenerateBase.php(83): Drupaldevel_generatePluginDevelGenerateTermDevelGenerate->generateElements(Array)
#10 0.555 #3 /opt/drupal/web/modules/contrib/devel/devel_generate/src/Commands/DevelGenerateCommands.php(282): Drupaldevel_generateDevelGenerateBase->generate(Array)
#10 0.555 #4 /opt/drupal/web/modules/contrib/devel/devel_generate/src/Commands/DevelGenerateCommands.php(159): Drupaldevel_generateCommandsDevelGenerateCommands->generate()
#10 0.555 #5 (internal function): Drupaldevel_generateCommandsDevelGenerateCommands->terms('10', Array)
#10 0.555 #6 /opt/drupal/vendor/consolidation/annotated-command/src/CommandProcessor.php(257): call_user_func_array(Array, Array)
#10 0.555 #7 /opt/drupal/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): ConsolidationAnnotatedCommandCommandProcessor->runCommandCallback(Array, Object(ConsolidationAnnotatedCommandCommandData))
#10 0.555 #8 /opt/drupal/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): ConsolidationAnnotatedCommandCommandProcessor->validateRunAndAlter(Array, Array, Object(ConsolidationAnnotatedCommandCommandData))
#10 0.555 #9 /opt/drupal/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(311): ConsolidationAnnotatedCommandCommandProcessor->process(Object(SymfonyComponentConsoleOutputConsoleOutput), Array, Array, Object(ConsolidationAnnotatedCommandCommandData))
#10 0.555 #10 /opt/drupal/vendor/symfony/console/Command/Command.php(255): ConsolidationAnnotatedCommandAnnotatedCommand->execute(Object(DrushSymfonyDrushArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#10 0.555 #11 /opt/drupal/vendor/symfony/console/Application.php(1027): SymfonyComponentConsoleCommandCommand->run(Object(DrushSymfonyDrushArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#10 0.555 #12 /opt/drupal/vendor/symfony/console/Application.php(273): SymfonyComponentConsoleApplication->doRunCommand(Object(ConsolidationAnnotatedCommandAnnotatedCommand), Object(DrushSymfonyDrushArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#10 0.555 #13 /opt/drupal/vendor/symfony/console/Application.php(149): SymfonyComponentConsoleApplication->doRun(Object(DrushSymfonyDrushArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#10 0.555 #14 /opt/drupal/vendor/drush/drush/src/Runtime/Runtime.php(118): SymfonyComponentConsoleApplication->run(Object(DrushSymfonyDrushArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#10 0.555 #15 /opt/drupal/vendor/drush/drush/src/Runtime/Runtime.php(49): DrushRuntimeRuntime->doRun(Array, Object(SymfonyComponentConsoleOutputConsoleOutput))
#10 0.555 #16 /opt/drupal/vendor/drush/drush/drush.php(72): DrushRuntimeRuntime->run(Array)
#10 0.555 #17 /opt/drupal/vendor/drush/drush/drush(4): require('/opt/drupal/ven...')
#10 0.555 #18 {main}.
#10 0.555 TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /opt/drupal/web/modules/contrib/devel/devel_generate/src/Plugin/DevelGenerate/TermDevelGenerate.php on line 377 #0 /opt/drupal/web/modules/contrib/devel/devel_generate/src/Plugin/DevelGenerate/TermDevelGenerate.php(377): count(NULL)
#10 0.555 #1 /opt/drupal/web/modules/contrib/devel/devel_generate/src/Plugin/DevelGenerate/TermDevelGenerate.php(197): Drupaldevel_generatePluginDevelGenerateTermDevelGenerate->generateTerms(Array)
#10 0.555 #2 /opt/drupal/web/modules/contrib/devel/devel_generate/src/DevelGenerateBase.php(83): Drupaldevel_generatePluginDevelGenerateTermDevelGenerate->generateElements(Array)
#10 0.555 #3 /opt/drupal/web/modules/contrib/devel/devel_generate/src/Commands/DevelGenerateCommands.php(282): Drupaldevel_generateDevelGenerateBase->generate(Array)
#10 0.555 #4 /opt/drupal/web/modules/contrib/devel/devel_generate/src/Commands/DevelGenerateCommands.php(159): Drupaldevel_generateCommandsDevelGenerateCommands->generate()
#10 0.555 #5 (internal function): Drupaldevel_generateCommandsDevelGenerateCommands->terms('10', Array)
#10 0.555 #6 /opt/drupal/vendor/consolidation/annotated-command/src/CommandProcessor.php(257): call_user_func_array(Array, Array)
#10 0.555 #7 /opt/drupal/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): ConsolidationAnnotatedCommandCommandProcessor->runCommandCallback(Array, Object(ConsolidationAnnotatedCommandCommandData))
#10 0.555 #8 /opt/drupal/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): ConsolidationAnnotatedCommandCommandProcessor->validateRunAndAlter(Array, Array, Object(ConsolidationAnnotatedCommandCommandData))
#10 0.555 #9 /opt/drupal/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(311): ConsolidationAnnotatedCommandCommandProcessor->process(Object(SymfonyComponentConsoleOutputConsoleOutput), Array, Array, Object(ConsolidationAnnotatedCommandCommandData))
#10 0.555 #10 /opt/drupal/vendor/symfony/console/Command/Command.php(255): ConsolidationAnnotatedCommandAnnotatedCommand->execute(Object(DrushSymfonyDrushArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#10 0.555 #11 /opt/drupal/vendor/symfony/console/Application.php(1027): SymfonyComponentConsoleCommandCommand->run(Object(DrushSymfonyDrushArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#10 0.555 #12 /opt/drupal/vendor/symfony/console/Application.php(273): SymfonyComponentConsoleApplication->doRunCommand(Object(ConsolidationAnnotatedCommandAnnotatedCommand), Object(DrushSymfonyDrushArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#10 0.555 #13 /opt/drupal/vendor/symfony/console/Application.php(149): SymfonyComponentConsoleApplication->doRun(Object(DrushSymfonyDrushArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#10 0.555 #14 /opt/drupal/vendor/drush/drush/src/Runtime/Runtime.php(118): SymfonyComponentConsoleApplication->run(Object(DrushSymfonyDrushArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#10 0.555 #15 /opt/drupal/vendor/drush/drush/src/Runtime/Runtime.php(49): DrushRuntimeRuntime->doRun(Array, Object(SymfonyComponentConsoleOutputConsoleOutput))
#10 0.555 #16 /opt/drupal/vendor/drush/drush/drush.php(72): DrushRuntimeRuntime->run(Array)
#10 0.555 #17 /opt/drupal/vendor/drush/drush/drush(4): require('/opt/drupal/ven...')
#10 0.555 #18 {main}
#10 0.555 TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in count() (line 377 of /opt/drupal/web/modules/contrib/devel/devel_generate/src/Plugin/DevelGenerate/TermDevelGenerate.php).
#10 0.560  (warning) Drush command terminated abnormally.

Dockerfile to reproduce:

FROM drupal:9.1.0

RUN composer require -n 
  drush/drush:10.3.6 
  drupal/devel:4.0.1

RUN apt-get update; apt-get install -y sqlite3
RUN mkdir /db; chown www-data:www-data /db
USER www-data

RUN cd /opt/drupal && drush site-install -y 
    --db-url=sqlite:///db/drupal.sqlite 
    --db-su=root 
    --db-su-pw=password 
    --account-name=admin 
    --account-pass=pass
USER root

RUN drush en -y devel devel_generate
RUN drush devel-generate:terms --bundles=tags 10

What makes me suspicious that I’ve done something wrong is the “Argument #1 ($value) must be of type Countable|array, null given” message. Have I missed an argument?

I looked at the output of drush devel-generate:terms --help doesn’t seem to suggest I’ve done anything wrong;

Create terms in specified vocabulary.

Arguments:
  (num) Number of terms to generate. (default: 50)

Options:
  --kill                        Delete all terms in these vocabularies before generating new ones.
  --bundles(=BUNDLES)           A comma-delimited list of machine names for the vocabularies where terms will be created.
  --feedback(=FEEDBACK)         An integer representing interval for insertion rate logging. (default: 1000)
  --languages(=LANGUAGES)       A comma-separated list of language codes
  --translations(=TRANSLATIONS) A comma-separated list of language codes for translations.
  --min-depth(=MIN-DEPTH)       The minimum depth of hierarchy for the new terms. (default: 1)
  --max-depth(=MAX-DEPTH)       The maximum depth of hierarchy for the new terms. (default: 4)

Aliases: gent, devel-generate-terms

8 – Database error when execute drush migrate:status

I’m trying to do a ‘file to media’ migration on a d8 installation. Following the readme on the module I have created a custom module and created the two yaml files. After enabling the module and drush ms i get the following error:

SQLSTATE(HY000) (2002) php_network_getaddresses: getaddrinfo failed

The error appears on my local (DDEV) and my production environment. Drush works otherwise. drush sql-cli works.

I think i’m missing something. Do i have to set a database reference somewhere?
Happy to provide additional information when needed, as i’m clueless atm.

Thanks for pointing me in the right direction.

8 – How can I use Drush in a project installed with Composer?

Just an addition for windows users.

lesley n. answer above works just fine for Windows users as well.

Just edit C:Usersyour_username.bash_profile and add one line:

alias drush='vendor/bin/drush'

Restart your Git Bash, go to your drupal site home folder and try:

drush version

It should work

I was able to make composer-installed Drupal Console to work with only “drupal” command also with one line addition to C:Usersyour_username.bash_profile as well:

alias drupal='vendor/bin/drupal'

Restart your Git Bash, go to your drupal site home folder and try:

drupal --version

This should work as well.

These two solutions are much easier for me than installing Drush Launcher and Console Launcher on my Windows platform.

drush – How to overcome error caused by non-existent service “entity.manager”?

Seems like Drush which came with the setup was not fully compatible.
I installed it again using the composer using

composer require drush/drush

It is working as expected.

Here is updated “require” section looks like in composer.json

   "require": {
        "composer/installers": "^1.9",
        "drupal/bootstrap_barrio": "^4.28",
        "drupal/bootstrap_sass": "^1.12",
        "drupal/core-composer-scaffold": "^9",
        "drupal/core-project-message": "^9",
        "drupal/core-recommended": "^9",
        "drush/drush": "^10.2"
    },

Drush 10, Drupal 9, views-bulk-operations:execute using entity:delete_action:node seems to work but won’t save its changes

I’m trying a command:
drush -vvv views-bulk-operations:execute -d deleteme_content entity:delete_action:node

where deleteme_content is a View with translations of entities that I want to delete. The command appears to work and prints a success message but the content is not actually deleted.

I’ve traced all the way into drupal/core/lib/Drupal/Core/Action/Plugin/Action/DeleteAction.php where I added some temporary logging messages and see in executeMultiple() that the desired entities are being changed in $this->tempStore.

So it looks to me like the changes are being made in tempStore but then not being “committed” to the permanent storage. I have looked for a “commit” type option in both drush and the vbo-execute command for drush and don’t see anything.

Can anyone provide a clue?

drush – Drupal root not found. Pass –root or a @siteAlias in order to see Drupal-specific commands

I have multiple sites inside the same htdocs directory. In one, I removed all the folders except vendor under Web. Now drush will not work (it worked before I moved the folders). But now, it cannot find the database, which is correctly defined in web/sites/default/settings.php

/srv/www/htdocs/jar/drupal # ./drush status
 PHP binary    : /usr/bin/php
 PHP config    : /srv/www/php.ini
 PHP OS        : Linux
 Drush script  : /srv/www/htdocs/jar/drupal/vendor/drush/drush/drush
 Drush version : 10.3.6
 Drush temp    : /tmp
 Drush configs : /srv/www/htdocs/jar/drupal/vendor/drush/drush/drush.yml
 Drupal root   : /srv/www/htdocs/jar/drupal

I am running Drupal 9.0.8 and drush 10.3.6 (in /srv/www/htdocs/jar/drupal). I have removed drush using composer (2.0.3) and reinstalled it (recreating vendor in the process).

/srv/www/htdocs/jar/drupal # ./drush -vvv cr
 (preflight) Config paths: /srv/www/htdocs/jar/drupal/vendor/drush/drush/drush.yml
 (preflight) Alias paths: /srv/www/htdocs/jar/drupal/drush/sites,/srv/www/htdocs/jar/drush/sites
 (preflight) Commandfile search paths: /srv/www/htdocs/jar/drupal/vendor/drush/drush/src
 (debug) Starting bootstrap to site (0.04 sec, 8.17 MB)

In BootstrapHook.php line 32:
  (Exception)
  Bootstrap failed. Run your command with -vvv for more information.
Exception trace:
  at /srv/www/htdocs/jar/drupal/vendor/drush/drush/src/Boot/BootstrapHook.php:32
 DrushBootBootstrapHook->initialize() at /srv/www/htdocs/jar/drupal/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php:44
 ConsolidationAnnotatedCommandHooksDispatchersInitializeHookDispatcher->doInitializeHook() at /srv/www/htdocs/jar/drupal/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php:36
 ConsolidationAnnotatedCommandHooksDispatchersInitializeHookDispatcher->callInitializeHook() at /srv/www/htdocs/jar/drupal/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php:29
 ConsolidationAnnotatedCommandHooksDispatchersInitializeHookDispatcher->initialize() at /srv/www/htdocs/jar/drupal/vendor/consolidation/annotated-command/src/CommandProcessor.php:145
 ConsolidationAnnotatedCommandCommandProcessor->initializeHook() at /srv/www/htdocs/jar/drupal/vendor/consolidation/annotated-command/src/AnnotatedCommand.php:296
 ConsolidationAnnotatedCommandAnnotatedCommand->initialize() at /srv/www/htdocs/jar/drupal/vendor/symfony/console/Command/Command.php:221
 SymfonyComponentConsoleCommandCommand->run() at /srv/www/htdocs/jar/drupal/vendor/symfony/console/Application.php:1018
 SymfonyComponentConsoleApplication->doRunCommand() at /srv/www/htdocs/jar/drupal/vendor/symfony/console/Application.php:271
 SymfonyComponentConsoleApplication->doRun() at /srv/www/htdocs/jar/drupal/vendor/symfony/console/Application.php:147
 SymfonyComponentConsoleApplication->run() at /srv/www/htdocs/jar/drupal/vendor/drush/drush/src/Runtime/Runtime.php:118
 DrushRuntimeRuntime->doRun() at /srv/www/htdocs/jar/drupal/vendor/drush/drush/src/Runtime/Runtime.php:49
 DrushRuntimeRuntime->run() at /srv/www/htdocs/jar/drupal/vendor/drush/drush/drush.php:72
 require() at /srv/www/htdocs/jar/drupal/vendor/drush/drush/drush:4

I looked at all the above suggestions, but am stuck. Drush works perfectly on my other 5 sites…

7 – Drush on server: Error: Allowed memory size issue

I have Drush installed on my Inmotion hosting server.
For one Drupal 7 site, it works just fine but for the other one, which is nearly identical, it doesn’t work so well.
Some commands it allows (like my favourite drush sql-dump or drush cc followed by 5) and but when I do a command drush cc all it throws an out-of-memory issue as shown below:

Drush command terminated abnormally due to an unrecoverable error.                                                                         (error)
Error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in
/home/myAccount/public_html/mysite.net/sites/all/modules/views/includes/base.inc, line 129

The issues stemming from the base.inc file are:

after command: drush cc all: on line 129:
$storage($option) = isset($definition('default')) ? $definition('default') : NULL;

The issues stemming from the view.inc file are:

after command: drush cc all: on line 2244:
$this->$field = unserialize($info('serialized default'));

after command: drush cc all: on line 2312:
$this->$field = empty($info('serialize')) ? $data->$field : unserialize($data->$field);

The php.ini files are identical on both sites.
The settings.php files are not identical and I thought it would be resolved by adding the same lines to the ending of the file

ini_set('memory_limit', '512M');
error_reporting(E_ALL);
$conf('error_level') = 2;
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

but this didn’t solve the problem (even after clearing the cache).

What could cause this problem?