Questions tagged as ['drush']
I'm playing around with the D9 Groups module and I want to test the access control in drush, either using drush php or writing a script and using drush scr.
In drush 8 I would always use drush -u to run as a specific user but that option seems to have disappeared in drush 10.
What's the easiest way to either run drush as a specific user or switch the user in drush php or a script?
Edit: I'm working aro ...

I currently use Drupal 9 but concepts about Drupal 10 may be useful.
I use Windows 10 Home with XAMPP and C:/xampp/htdocs
is my web application root.
I want to establish a minimal Drupal development environment on my Windows 10 Home instance by installing Composer and then Drush.
I can use WSL to install both Composer and Drush but then a question arises:
If WSL only effects its own Linux environment, ho ...
I am the administrator of a Drupal site replicated on 4 servers, behind a load balancer. There is only one database that is shared by the 4 instances. When I run drush cr, is it necessary to run it on each of the 4 nodes, or is it enough to run it on only one?
I was trying to create a new Content Type for my site and I chose a field name ("description") that already used for other content types.
The problem occurred when saving changes as the machine name for the field already exists for the fields in other Content Types but with a different field type. In other Content types I used the default "Long Text" field type but in this case I chose "Read More ...

I just install a Drupal 9.2 site and Drush 10 to manage it. Usually I use Drush 9 and Drupal 8.9.
It appear option for pml command seem not to work in Drush 10 as it do in Drush 9. Example:
drush @pfdevd9pf pml --filter=rss
The "--filter" option does not exist.
drush @pfdevd9pf pml | grep "rss"
RRSSB Ridiculously Responsive Social Share Buttons (rrssb) Disabled 8.x-2.3
This is a weird thing, th ...
I have an existing custom module on my D9 website and I need to make some changes inside it. I want to add a field (boolean) into any content type page edit without doing it manually.
So I need my field to be available here /admin/structure/types/manage/mycontenttype/fields/add-field
On my CLI, i've run this command drush generate field
, which gave me those files :
modules/custom/mymdule/config/ ...

I'm running a long drush script and its causing memory problems.
Then I tried debbuging it and I have this very simple code:
$query = \Drupal::entityTypeManager()->getStorage('user');
foreach ($emails as $i => $email) {
$users = $query->loadByProperties(['mail' => $email]);
$user = reset($users);
unset($user);
unset($users);
}
When I ran the script I noticed that the memory ...

I am doing some D8 to D9 migrations and having a problem with a multisite. I upgraded my local version to drush 10 as well as on my dev server and included the drush/sites/us2.site.yml
file.
I can sql-sync the default db no problem, but when I try and specify a --uri
it still targets my default database.
drush sql-sync @us2.dev @self
says it will replace us2_local
with us2dev
which is correct.
drush s ...
I crafted my drush/sites/self.site.yml like below* and verified that drush rsync @prod:%files @self:%files
worked. However, drush sql-sync @prod @self
results in the following error:
The command "/usr/local/bin/drush sql-query --strict=0 --file=/tmp/termitral_db_20211011_110905.sql.gz --file-delete --uri=drupal --root=/var/www/drupalvm/drupal/web" failed.
Exit Code: 1(General error)
Working dir ...
My server currently is using PHP 7.1 but I need to run PHP 7.4 during my drush commands on one of my sites. The following works for almost all commands:
/path/to/my/php74 ../vendor/bin/drush cr
/path/to/my/php74 ../vendor/bin/drush cim -y
But when I run the update database command I get an error:
/path/to/my/php74 ../vendor/bin/drush updb -y
or:
export DRUSH_PHP=/path/to/my/php74 && /pa ...
I usually take backup of the entire database before importing new configurations, but this time I didn't and now I need to double check something with old version of database. Is it possible to just revert the changes done by drush cim
?
I am using Drupal 8.
Googling for this specific situation didn't give me any solution.
I'm trying to run
ddev exec drush state:set system.maintenance_mode 1
With MAMP drush state:set system.maintenance_mode 1
works fine.
With ddev I get the error:
Too many arguments, expected arguments "command" "key".
I've tried every possible variation of this command I could think of, also using ddev ssh. Nothing works.
Am I missing something? Is this impossible with ddev?

We have a custom Drush command implemented using the following code.
class JobApplicationExportCommands extends DrushCommands {
/**
* Exports Dorea Job Applications since the last run to csv
*
* @command dummy:job-application-export
* @aliases duje
*/
public function drush_dummy_export() {
$applicationWebformIds = Drupal::entityQuery('webform')
->condition('category', ...
I've run into the following error when running the command drush migrate-import custom_spotlight
where custom_spotlight
is the name of the plugin. I've been following along with this guide: https://www.metaltoad.com/blog/drupal-8-migrations-part-4-migrating-nodes-drupal-7 but I'm not exactly sure what went wrong here. It seems when the placeholder :nid
is substituted with a value, there are quotes inserte ...

I'm sure there is a simple fix, but I can't figure it out. This is my error every time I try to run drush updatedb
$ drush updatedb
Box Requirements Checker
========================
> Using PHP 8.0.9
> PHP is using the following php.ini file:
/etc/php/php.ini
> Checking Box requirements:
..E.........
...
I am trying to uninstall Lightning. When I run drush pm:uninstall lightning
, it throws this error.
In PmCommands.php line 196:
lightning: The Lightning module is required
How can I resolve this?
I'm migrating Drupal 7 commerce products to Drupal 9 and I'm using:
- Drush (10.5.0)
- migrate_plus
- migrate_tools
- commerce_migrate_commerce
- commerce_migrate
I have successfully migrated nodes, but I cannot migrate fields. In other words, I have node titles and bodies, but not all the additional fields I have on Drupal 7.
I used the following migration IDs.
- d7_file
- d7_user
- d7_node_complete:general_product ...
I've two environment, dev and staging. I'm using the ReCaptcha module.
In the developpement environment, I have some api keys a other config which until now, are exported thanks to drush cex
inside the recaptcha.settings file
site_key: mysite_key
secret_key: mysite_secret
verify_hostname: false
use_globally: false
widget:
theme: dark
type: image
size: ''
tabindex: 0
noscript: false
_core: ...

We have two websites running off a single domain:
https://www.mywebsite.com/mywebsitetools
Both websites have their own databases and are hosted by Acquia.
We've been using Drush 8.x and the sql-sync command for the past number of years to synchronizing the database between the local environment and Acquia.
Last week we upgraded to using Drush 10.3.6 and now we're running i ...
I am not very familiar with PHP, Drupal and drush but I inherited a site running on Windows Server 2019 (in the process of being migrated from Ubuntu). When I want to download some webforms using drush wfx
, special characters like German "Umlaute" ä, ö and ü in the webform contents are not correctly displayed.
I am running Drupal 7.81 und using drush 7.0.0. I also tried to specifially set the encodin ...

I installed PHP 7.4.21, then Drupal 9.2.1, and Drush 10.5.0 with Composer as well.
Running Drush without arguments, I get the list of all the available commands.
Running drush cr
gives me the following error.
The specified database connection is not defined: default
drush cr --root=/home/ip/d916/web
gives the same error.
The output of drush cr -vvv
is the following.
Exception trace
at /home/ip/d916/w ...

I want to bulk create about 2-300 users with Drush on a Drupal 8 site. I want each of them to receive a welcome email and be forced to set up their own passwords. This can be done trivially with the "Notify user of new account" option through the UI but I cannot seem to make it work with Drush 9.
I can run a script that reads from a CSV and creates the user, then gives them the needed roles, howe ...
Similar with but not the same as How to use drush config:set for translations?, is there a way to scan for a site's language config changes via drush or so?
I have a lot of sites on the same server (multi-site), and I would rather check on this via a drush command than having to log in each of the sites to look at the output of /admin/config/development/configuration
.
For normal config changes I could ...
Greetings to all of you.
Drush seems unable to properly find the site.
The output of vendor/drush/drush/drush status
PHP binary : /usr/bin/php
PHP config : /etc/php.ini
PHP OS : Linux
Drush script : /usr/share/site_dir/vendor/drush/d ...

I'm working on a site installed with Composer. After the local installation broke, I'm trying to reinstall the project from source code and the MySQL database. All the sources are versioned on Git (including the /vendor folder).
After Acquia installation, all the pages return a 500 error. When I run drush ws
to debug, I get the following error message.
Drupal\Core\DependencyInjection\ContainerNotInitial ...
I want to export one or more specific rules or components using Drush.
I do have a script to export all the rules and components.
drush --pipe rules-list | xargs -I{} sh -c "drush rules-export '{}' > '20210623-new-Rules-export-offline/{}.txt'"
20210623-new-Rules-export-offline is the directory where the exported rules are saved.
Is there something I need to change to this code in order to export th ...
I have a multi-site Drupal 8 install and Drush has stopped working. All Drush commands fail with a "Bootstrap failed" error.
"Drush status" shows the /web dir twice as the root. Manually adding the root (--root:path) results in the same 'Bootstrap Failed" error
Any idea why the web directory would show twice in the root?
SITE@mi3-sr25 [~/public_html/web]# drush status
PHP binary : /opt/alt/php73/usr/ ...

When I open Terminal on the david/Sites/animals directory, and I run drush site-install --db-url=mysql://david:root@localhost:3306/animals
, the get the following error.
In SiteInstallCommands.php line 152: Drush was unable to drop all tables because
mysql
was not found, and therefore Drupal threw an AlreadyInstalledException. Ensuremysql
is available in your PATH.
Did I write the correct comma ...

Using drush either globally or with a composer installed version, I get this double includes showing up in my fatal error (/includes/includes/):
include_once(/srv/www/htdocs/sites/drupal/includes/includes/entity.inc): failed to open stream: No such file or directory bootstrap.inc:3492 [warning] include_once(): Failed opening '/srv/www/htdocs/sites/drupal/includes/includes/entity ...
After I updated my site to Drupal 8.9.16 and Drush to 10.5.0 I get the following error PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function
when running any Drush command. This only happens on my remote site not on my local site.
The site is still working ok so I was able to clear cache and update the database from the backend of Drupal. I was hoping this would fix the problem bu ...