Problem/Motivation
php core/scripts/drupal server will fail with the following error if it is not executed from Drupal's root directory:
In Connection.php line 123:
SQLSTATE[HY000] [14] unable to open database file
In Connection.php line 119:
SQLSTATE[HY000] [14] unable to open database fileSteps to reproduce
Install Drupal via Composer using the drupal/recommended-project template.
composer create-project drupal/recommended-project:^9.0.0 drupal9
cd drupal9
php web/core/scripts/drupal quick-start
# Press Ctrl-C to quit the Drupal development server.
php web/core/scripts/drupal server
# Command fails with above error.
The ServerCommand command does not fail if executed from the web directory.
composer create-project drupal/recommended-project:^9.0.0 drupal9
cd drupal9/web
php ./core/scripts/drupal quick-start
# Press Ctrl-C to quit the Drupal development server.
php ./core/scripts/drupal server
# Command works.
Proposed resolution
Similar to the InstallCommand, change directory to Drupal's root early in the execute method.
Remaining tasks
Provide patch.Review manually.- Write test.
Results of manual testing
@adhershmnair successfully manually tested the proposed resolution.
User interface changes
None.
API changes
None.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | after-patch-3150146-2-servercommand.png | 49.58 KB | adhershmnair |
| #5 | before-patch-3150146-2-servercommand.png | 28.41 KB | adhershmnair |
| #2 | 3150146-2-servercommand.patch | 613 bytes | dinarcon |
Issue fork drupal-3150146
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:
Comments
Comment #2
dinarcon commentedAttached is a patch with the proposed solution. No automated test yet.
Comment #3
kristen polThanks for the issue and patch. The code looks straight forward. Tagging for manual testing.
Comment #4
adhershmnair commentedComment #5
adhershmnair commentedVerified and tested by applying patch #2.
It is working fine for D9
Before applying patch.

After applying patch.

Comment #6
quietone commentedThanks for making it easier to use the script.
I read the Issue Summary and it shows that there are two remaining tasks and this is tagged as Needs manual testing. I skimmed the issue and it looks like that has been done. So the IS needs to be updated and it should include the results of manual testing and the tags need updating as well. If we do that it is easier for the committers and anyone searching by 'needs manual testing' won't wind up here and spend time figuring out that manual testing is already done. Thanks!
Comment #13
pingwin4egTrying to run
php web/core/scripts/drupal serverin D11 I get another error:The patch applies and fixes the error.
The only remaining task is probably to write a test case. I'm not sure about the directory structure in the testing environment, is there a "web" (or another docroot) directory?
Comment #16
adhershmnair commentedComment #17
smustgrave commentedLeft comments on the MR.