ComposerValidator's hook_help() integration is imprecise and incomplete

Created on 2 May 2023, over 1 year ago
Updated 8 May 2023, over 1 year ago

Problem/Motivation

Discovered by @tedbow at 🐛 Improve hook_help() to explain the actual Composer requirements Fixed .

In ComposerValidator, we do this (abbreviated)

    try {
      $this->composerInspector->validate($dir);
    }
    catch (\Throwable $e) {
        $message = $this->t('@exception_message See <a href="/admin/help/package_manager#package-manager-faq-composer-not-found">the help page</a> for information on how to configure the path to Composer.');
        $event->addError([$message]);
    }

This blithely assumes that the reason ComposerInspector::validate() threw an exception is because the path to Composer was not known. That may not be the case, in fact -- it could be that composer validate failed for some other reason.

This is basically a relic from when this try-catch wrapped around the ExecutableFinder service, and threw if it couldn't find Composer.

Proposed resolution

We need to update hook_help() to ensure that we're explaining the things that could actually cause this exception, and how to mitigate them. Such as:

  • The Composer executable was not found.
  • It was found, but it is not a supported version.
  • The call to composer validate failed for some reason. We should link to Composer's documentation to explain why it might.

When there is an exception, we can just link to the section of our help where we explain our expectations around Composer. We don't need to link to specific explanations of the specific error that was received -- that would be a massive increase in complexity for very little benefit. It's okay to expect people to read a few lines of documentation, I think.

🐛 Bug report
Status

Fixed

Version

3.0

Component

Documentation

Created by

🇺🇸United States phenaproxima Massachusetts

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

Comments & Activities

Production build 0.71.5 2024