Add global for command line scripts

Created on 20 February 2025, 3 months ago

Problem/Motivation

The recipe runner skips validation if the $install_state global exists. This global is set by the installer. There is currently no way to skip validation when applying recipes from the command line without the installer.

I am building a CMS demo image for low powered hosting. To shorten installation time, I run the installer up to the user name and password step and then apply recipes on the command line before saving the image. Whether or not you think I should be doing this, it works well, and build reliability would be greatly improved by skipping recipe validation on the command line the way the installer does.

Steps to reproduce

  1. Run the installer up to the user name and password step.
  2. Apply a recipe from the command line: ddev drush recipe ../recipes/drupal_cms_starter.
  3. Observe validation errors.

Proposed resolution

Initialize the $install_state global in the install profile. The Drupal CMS install profile is uninstalled after installation completes, so this is a reliable way to detect that installation is in progress.

User interface changes

None.

Data model changes

None.

✨ Feature request
Status

Active

Component

Track: Installer

Created by

πŸ‡ΊπŸ‡ΈUnited States darren oh Lakeland, Florida

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @darren oh
  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

    The Recipe command is provided by core, not Drupal CMS, and it is extremely weird for us to explicitly initialize install_state (to an empty array, no less, which might break all kinds of shit) in an install profile, where we can pretty much be guaranteed that it already exists, because install profiles only ever run in the installer.

    I'm moving this to core, since this sounds like something that needs to be fixed there.

  • Pipeline finished with Failed
    3 months ago
    Total: 813s
    #429762
  • πŸ‡ΊπŸ‡ΈUnited States darren oh Lakeland, Florida

    I'll grant that I did not present the full technical case for this in the description. Core already skips validation during installation. If you look at my code, you will see that the $install_state global is initialized to an empty array only if it does not exist. There is zero chance that this will break anything. As I explained, without this change the global variable will not exist for command line scripts that run while installation is paused.

  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts
  • Pipeline finished with Canceled
    3 months ago
    #432112
  • Pipeline finished with Failed
    3 months ago
    Total: 1742s
    #432114
  • πŸ‡ΊπŸ‡ΈUnited States darren oh Lakeland, Florida

    Unless there is a plan to remove the Recipe Installer Kit package after installation I don't know what this has to do with the Recipe Installer Kit. However, I did find that, contrary to what I was told by the Drush maintainers, global PHP variables can be set on the command line using the --include option to include a command file that sets a global variable in its class constructor.

  • πŸ‡ΊπŸ‡ΈUnited States thejimbirch Cape Cod, Massachusetts

    Moving back to Needs work as the PHP tests are failing.

Production build 0.71.5 2024