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 file

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

Issue fork drupal-3150146

Command icon 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

dinarcon created an issue. See original summary.

dinarcon’s picture

Status: Active » Needs review
StatusFileSize
new613 bytes

Attached is a patch with the proposed solution. No automated test yet.

kristen pol’s picture

Thanks for the issue and patch. The code looks straight forward. Tagging for manual testing.

adhershmnair’s picture

Assigned: Unassigned » adhershmnair
adhershmnair’s picture

Assigned: adhershmnair » Unassigned
Status: Needs review » Reviewed & tested by the community
Issue tags: +ContributionWeekend2020
StatusFileSize
new28.41 KB
new49.58 KB

Verified and tested by applying patch #2.
It is working fine for D9

Before applying patch.
Before applying patch #2

After applying patch.
After applying patch #2

quietone’s picture

Status: Reviewed & tested by the community » Needs work

Thanks 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!

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

pingwin4eg’s picture

Component: install system » other
Issue summary: View changes
Issue tags: -Needs manual testing

Trying to run php web/core/scripts/drupal server in D11 I get another error:

The service file "core/core.services.yml" is not valid.

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?

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

adhershmnair’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Needs work

Left comments on the MR.