Problem/Motivation
Deployment and CI scripts often need to know whether a site is installed, to choose between installing it and updating it. With Drush this is drush status --field=bootstrap. With dr, the only check is a side effect: dr status exits 1 with "Command "status" is not defined" before an install, because system:status comes from the System module, and DrupalApplication only adds module commands once Drupal boots. Any boot failure looks the same, and the message doesn't say what's wrong.
Core has two checks for this, and they disagree:
InstallCommand::isDrupalInstalled()(protected) only checks that settings.php has database connection info, so a site whose install didn't finish counts as installed.InstallerRedirectTrait::shouldRedirectToInstaller()also checks that thekey_valuetable exists, but only runs for web requests.
Steps to reproduce
- Create a new project with
composer create-project drupal/recommended-project. - Run
vendor/bin/dr status; echo $?: it prints "Command "status" is not defined." and1. - Install the site with
vendor/bin/dr install minimal, then run step 2 again: it prints the status table and0.
Proposed resolution
- Move the check into one public
InstallerKernel::isSiteInstalled()method that tests both the connection info and thekey_valuetable and uses the installer's install_task/install_time rule, and use it inInstallCommandandInstallerRedirectTrait. - Expose it to
drbefore Drupal boots with new defaultsite:installed/is-installedcommand inDrupalApplicationthat exits 0 when installed and 1 when not.
Remaining tasks
- Agree on the method, command name and behavior
- Implement and test it
Related issues
- #3453474: CLI entry point in Drupal Core: CLI entry point in Drupal core
- #3089277: Provide core CLI commands for the most common features of Drush: Provide core CLI commands for the most common features of Drush
Generated with the help of an LLM
Claude Code drafted this summary and checked the behavior on Drupal 11.4.13; I reviewed it.
Issue fork drupal-3641324
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3641324-dr-installed-check
changes, plain diff MR !17924
- 3641324-add-dr-installed
compare
Comments
Comment #2
dave reidComment #5
dave reid