Skip to content

Commit

Permalink
Update docs and exceptions related to --root (#6035)
Browse files Browse the repository at this point in the history
  • Loading branch information
weitzman authored Jun 14, 2024
1 parent ba5b8ba commit 32c642b
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/bootstrap.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Only run Drush _preflight_, without considering Drupal at all. Any code that ope

root
------------------------------
Set up and test for a valid Drupal root, either through the --root options, or evaluated based on the current working directory. Any code that interacts with an entire Drupal installation, and not a specific site on the Drupal installation should use this bootstrap phase.
Set up and test for a valid Drupal root. The root is usually discovered via the [Composer Runtime API](https://getcomposer.org/doc/07-runtime.md#knowing-the-path-in-which-a-package-is-installed), looking for the path of the__drupal/core__ package. Any code that interacts with an entire Drupal installation, and not a specific site on the Drupal installation should use this bootstrap phase.

site
------------------------------
Expand Down
4 changes: 2 additions & 2 deletions docs/cron.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ By default, Drush will print a success message when the run of cron is completed
Specifying the Drupal site to run
---------------------------------

There are many ways to tell Drush which Drupal site to select for the active command, and any may be used here. The example uses `cd [DOCROOT]`, but you could also use the --root and --uri flags.
The Drupal root is derived from which `drush` you call. The Drupal docroot is usually discovered via the [Composer Runtime API](https://getcomposer.org/doc/07-runtime.md#knowing-the-path-in-which-a-package-is-installed), looking for the path of the__drupal/core__ package. Use the --uri to control which multisite to target within the docroot (if applicable).

Avoiding Maintenance mode
---------------------------------

The call to maint:status checks to see if the site is in maintenance mode. If yes, cron will not run and the command returns a failure. It is not safe to run cron while the site is in maintenance. See https://drupal.slack.com/archives/C45SW3FLM/p1675287662331809.
The call to maint:status checks to see if the site is in maintenance mode. If yes, cron will not run and the command returns a failure. It is not safe to run cron while the site is in maintenance. See https://drupal.slack.com/archives/C45SW3FLM/p1675287662331809.
4 changes: 1 addition & 3 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ For even more documentation, use the [topic command](commands/core_topic.md):

$ drush topic

Using the --uri option and --root options.
Using the --uri option.
-----------

For multi-site installations, use a site alias or the --uri option to target a particular site.

$ drush --uri=http://example.com pm:install

If you are outside the Composer project and not using a site alias, you need to specify --root and --uri for Drush to locate and bootstrap the right Drupal site.

Site Aliases
------------

Expand Down
2 changes: 1 addition & 1 deletion src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ protected function bootstrapAndFind($name)

if (!$this->bootstrapManager()->hasBootstrapped(DrupalBootLevels::ROOT)) {
// Unable to progress in the bootstrap. Give friendly error message.
throw new CommandNotFoundException(dt('Command !command was not found. Pass --root or a @siteAlias in order to run Drupal-specific commands.', ['!command' => $name]));
throw new CommandNotFoundException(dt('Command !command was not found. Make sure that the `drush` you are calling is a dependency of a your site\'s composer.json', ['!command' => $name]));
}

// Try to find it again, now that we bootstrapped as far as possible.
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/core/CacheCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public function validate(CommandData $commandData): void
if (!$this->bootstrapManager->hasBootstrapped(DrupalBootLevels::FULL)) {
$all_types = $this->getTypes(true);
if (array_key_exists($type, $all_types)) {
throw new \Exception(dt("'!type' cache requires a working Drupal site to operate on. Use the --root and --uri options, or a site @alias, or cd to a directory containing a Drupal settings.php file.", ['!type' => $type]));
throw new \Exception(dt("'!type' cache requires a working Drupal site to operate on. Make sure that the `drush` you are calling is a dependency of a your site\'s composer.json. The --uri option might also help.", ['!type' => $type]));
} else {
throw new \Exception(dt("'!type' cache is not a valid cache type. There may be more cache types available if you select a working Drupal site.", ['!type' => $type]));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/help/ListCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function helpList($options = ['format' => 'listcli', 'raw' => false, 'fil
$preamble = dt('Run `drush help [command]` to view command-specific help. Run `drush topic` to read even more documentation.');
$this->renderListCLI($application, $namespaced, $this->output(), $preamble);
if (!Drush::bootstrapManager()->hasBootstrapped((DrupalBootLevels::ROOT))) {
$this->io()->note(dt('Drupal root not found. Pass --root or a @siteAlias in order to see Drupal-specific commands.'));
$this->io()->note(dt('Drupal root not found. In order to see Drupal-specific commands, make sure that the `drush` you are calling is a dependency in your site\'s composer.json. The --uri option might also help.'));
}
return null;
} elseif ($options['format'] == 'xml') {
Expand Down

0 comments on commit 32c642b

Please sign in to comment.