Problem/Motivation

A low level failure trying to run a Composer command in \Drupal\package_manager\Validator\ComposerExecutableValidator::validateStagePreOperation will throw an error that "Update readiness check" displays on the Status page with the message about configuring the path to Composer--which has nothing to do with it. Example:

The process has been signaled with signal "9". See the help page for information on how to configure the path to Composer.

Steps to reproduce

The exact cause of the failure when this issue was discovered has not yet been identified. However, it can be simulated by throwing a \PhpTuf\ComposerStager\Domain\Exception\RuntimeException from \Drupal\package_manager\Validator\ComposerExecutableValidator::runCommand--which seems to be the locus of the problem.

Proposed resolution

Identify the absence of Composer using \PhpTuf\ComposerStager\Domain\Service\Precondition\ComposerIsAvailableInterface before even trying to run Composer commands, rather than trying to run one and then trying to distinguish between failure conditions.

Remaining tasks

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

TravisCarden created an issue. See original summary.

tedbow’s picture

Issue tags: +sprint
wim leers’s picture

This seems like very important hardening that would make AU more reliable overall. Tempted to put it in #3319030: Drupal Core Roadmap for Package Manager and Update Manager under Reliability, but it seems rare/edge case-y enough that it's not worth listing there.

I do worry that we need this nonetheless to be confident that doing this at a later time won't trigger API changes though?

yash.rode’s picture

Assigned: Unassigned » yash.rode
Status: Active » Needs work

yash.rode’s picture

StatusFileSize
new415.82 KB

Tried reproducing it, is this the expected behaviour?
screeenshot of error

yash.rode’s picture

Assigned: yash.rode » wim leers
Status: Needs work » Needs review
wim leers’s picture

Assigned: wim leers » yash.rode
Status: Needs review » Needs work

#7: Almost. You threw a \RuntimeException, but @TravisCarden said in the issue summary it's a \PhpTuf\ComposerStager\Domain\Exception\RuntimeException. Subtle but important difference! 🤓

yash.rode’s picture

Assigned: yash.rode » wim leers
Status: Needs work » Needs review
StatusFileSize
new272.26 KB

I will get screeenshot of bug on using \PhpTuf\ComposerStager\Domain\Exception\RuntimeException

wim leers’s picture

Assigned: wim leers » traviscarden

Well that seems sensible/plausible because it's a PhpTuf\ComposerStager\Domain\Exception\IOException.

Assigning to @TravisCarden to clarify and review. He's the maintainer of that package, so he'll know 😊

traviscarden’s picture

Assigned: traviscarden » yash.rode
Issue summary: View changes

Well, the answer the question exactly as you asked it is that you would need to catch \PhpTuf\ComposerStager\Domain\Exception\LogicException. (See ComposerRunnerInterface::run.) But that doesn't get us all the way there, because other conditions can also throw that exception, and it's impossible to reliably tell the difference between them. (The other known one is if proc_open() is unavailable, a requirement peculiar to Symfony Process.)

Having through more about it, I propose a different approach: rather than trying to run a Composer command and then identify exactly what went wrong, let's just test for our special case first and handle it cleanly. Just use \PhpTuf\ComposerStager\Domain\Service\Precondition\ComposerIsAvailableInterface::isFulfilled(). I've updated the issue summary with my new proposed resolution.

yash.rode’s picture

Status: Needs review » Needs work
yash.rode’s picture

Assigned: yash.rode » wim leers
Status: Needs work » Needs review
tedbow’s picture

Assigned: wim leers » traviscarden
traviscarden’s picture

Assigned: traviscarden » wim leers

Back to you, @Wim Leers!

wim leers’s picture

Assigned: wim leers » Unassigned
Status: Needs review » Reviewed & tested by the community

There are 2 nits that should still be applied, but for some reason I can't apply them even though I have push access to https://git.drupalcode.org/project/automatic_updates/-/merge_requests/616 😬

Still: RTBC!

traviscarden’s picture

I was able to commit the nits, @Wim Leers. It's ready to go.

wim leers’s picture

🚢

tedbow’s picture

Assigned: Unassigned » tedbow

Going to commit this as is. But I have 1 question about a possible follow-up in an MR comment

  • badd608 committed on 8.x-2.x
    Issue #3320836 by yash.rode, TravisCarden, tedbow: Handle runtime error...
tedbow’s picture

Status: Reviewed & tested by the community » Fixed

thanks all!

tedbow’s picture

Issue tags: +core-mvp

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.