Questions tagged as ['drush']

Use it for questions about the command line shell and Unix scripting interface for Drupal (a.k.a. Drush).
Score: 2
Lambic avatar
How do I switch user account in drush to test permissions?
ph flag

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 ...

Score: 0
Is it possible to use WSL-based Drush on a Windows 10 XAMPP and if so how?
mu flag

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 ...

Score: 2
richirm avatar
drush cr on replicated servers
in flag

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?

Score: 0
pazitos10 avatar
SQL Error when trying to remove content type field
np flag

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 ...

Score: -1
Options for pml command with Drush 10
us flag

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 ...

Score: 0
mt.i.1 avatar
Adding custom field generated by drush to available fields on node
us flag

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/ ...
Score: 3
Drush script memory problem
us flag

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);


When I ran the script I noticed that the memory  ...

Score: 0
Drush 10 sql-sync and multi site --uri not working
in flag

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/ 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 @self says it will replace us2_local with us2dev which is correct.

drush s ...

Score: 1
Kartagis avatar
How can I fix this query error with drush sql-sync?
lu flag

I crafted my drush/sites/ 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 ...
Score: 1
albertski avatar
Can't change PHP version during Drush update database command
cn flag

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


export DRUSH_PHP=/path/to/my/php74 && /pa ...
Score: 0
Naser Nikzad avatar
Is there any way to revert the changes done by "drush cim"?
us flag

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.

Score: 0
Arthur Sauer avatar
ddev Too many arguments, expected arguments "command" "key"
cz flag

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?

Score: 0
Calling setExposedInput() from a Drush command doesn't have any effect
ve flag

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', ...
Score: 0
Sam Ng avatar
Custom Migration Plugin MySQL Error
ck flag

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: 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 ...

Score: 0
Drush fails with PHP 8 due to padraic/humbug_get_contents requirements
cn flag

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:

> Checking Box requirements:

Score: 0
Akshar Vijay avatar
Uninstalling Lightning causes an error
in flag

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?

Score: 1
NBayaman avatar
How do I migrate product fields?
in flag

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 ...
Score: 3
mt.i.1 avatar
Exclude settings from a contrib module on export
us flag

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
  theme: dark
  type: image
  size: ''
  tabindex: 0
  noscript: false
_core: ...
Score: 0
Using Drush 10 and sql-sync with path based sites not working
in flag

We have two websites running off a single domain:

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 ...

Score: 0
jo0815 avatar
Encoding problems in drush 7 running on Windows
cn flag

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 ...

Score: 3
How can I fix the "The specified database connection is not defined: default" error?
cn flag

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 ...

Score: 1
Bulk user creation and email notification
do flag

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 ...

Score: 4
baikho avatar
drush config-status on translation / language config files?
us flag

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  ...

Score: 0
Balde Binos avatar
Drush 10 is not working - seems unable to properly find the site
br flag

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 ...
Score: 0
$container not initialized after installation from sources (code and database)
cn flag

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 ...

Score: 0
BassPlaya avatar
How to export 1 or several specific rules?
ma flag

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 ...

Score: 0
quantumized avatar
Drush won't run, 'status' shows web directory twice
ng flag

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/ ...
Score: -2
I am unable to run "drush site-install" without getting errors
us flag

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. Ensure mysql is available in your PATH.

Did I write the correct comma ...

Score: 0
Drush issue duplicating includes/ directory
za flag

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/ failed to open stream: No such file or directory [warning] include_once(): Failed opening '/srv/www/htdocs/sites/drupal/includes/includes/entity ...

Score: 1
Joost avatar
PHP Fatal error: Uncaught ArgumentCountError on Drush run
jp flag

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 ...