stage exception when trying to add and install a module in a project using the drupal-core-development-project composer template

Created on 4 July 2024, 2 months ago
Updated 10 July 2024, about 2 months ago

Problem/Motivation

I've started using https://github.com/joachim-n/drupal-core-development-project recently. With that composer template the drupal repository is git cloned into the ./repos folder and then symlinked into ./web. project_browser was also git cloned into the repos folder while automatic updates was just composer required. I now ran into the following stage exception when i tried to add and install a module in project browser via the ui:

Drupal\package_manager\Exception\StageException: Failed to run process: <em class="placeholder">The command &quot;&#039;/usr/local/bin/composer&#039; &#039;--working-dir=/tmp/.package_manager8a237b64-eeaf-4e27-a9f2-591a1da9a44e/nhbkTMu8pC32glGuftDEPWq70bwrc1WB&#039; &#039;require&#039; &#039;--no-update&#039; &#039;drupal/ctools&#039;&quot; failed. Exit Code: 1(General error) Working directory: /var/www/html/web Output: ================ Error Output: ================ In PathRepository.php line 163: The `url` supplied for the path (repos/drupal) repository does not exist require [--dev] [--dry-run] [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--fixed] [--no-suggest] [--no-progress] [--no-update] [--no-install] [--no-audit] [--audit-format AUDIT-FORMAT] [--update-no-dev] [-w|--update-with-dependencies] [-W|--update-with-all-dependencies] [--with-dependencies] [--with-all-dependencies] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [-m|--minimal-changes] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--] [&lt;packages&gt;...] </em>. #0 /var/www/html/web/modules/contrib/automatic_updates/package_manager/src/StageBase.php(440): Drupal\package_manager\StageBase->rethrowAsStageException() #1 /var/www/html/web/modules/contrib/automatic_updates/package_manager/src/StageBase.php(449): Drupal\package_manager\StageBase->Drupal\package_manager\{closure}() #2 /var/www/html/repos/project_browser/src/Controller/InstallerController.php(427): Drupal\package_manager\StageBase->require() #3 [internal function]: Drupal\project_browser\Controller\InstallerController->require() #4 /var/www/html/repos/drupal/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array() #5 /var/www/html/repos/drupal/core/lib/Drupal/Core/Render/Renderer.php(593): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #6 /var/www/html/repos/drupal/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext() #7 /var/www/html/repos/drupal/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() #8 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(183): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #9 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw() #10 /var/www/html/repos/drupal/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle() #11 /var/www/html/repos/drupal/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle() #12 /var/www/html/repos/drupal/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle() #13 /var/www/html/repos/drupal/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle() #14 /var/www/html/repos/drupal/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\big_pipe\StackMiddleware\ContentLength->handle() #15 /var/www/html/repos/drupal/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass() #16 /var/www/html/repos/drupal/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle() #17 /var/www/html/repos/drupal/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() #18 /var/www/html/repos/drupal/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() #19 /var/www/html/repos/drupal/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle() #20 /var/www/html/repos/drupal/core/lib/Drupal/Core/DrupalKernel.php(709): Drupal\Core\StackMiddleware\StackedHttpKernel->handle() #21 /var/www/html/web/index.php(19): Drupal\Core\DrupalKernel->handle() #22 {main}

If i remember correctly project browser isnt working if there are any symlinks in place? is that still the case? at least the error message itself isnt very helpful or better overwhelming for less technical folks?

p.s. I've raised the issue already over in https://drupal.slack.com/archives/C01UHB4QG12/p1720089140828889?thread_t... as well as informed @joachim the maintainer of the composer template. per @joachim's request i've opened up this issue, cuz according to him the fix might be an fairly easy one "PB should tweak the URLs of path repos when it copies the composer.json into the staging folder"

Steps to reproduce

Proposed resolution

๐Ÿ“Œ Task
Status

Active

Version

2.0

Component

Code

Created by

๐Ÿ‡ฉ๐Ÿ‡ชGermany rkoller Nรผrnberg, Germany

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

Comments & Activities

  • Issue created by @rkoller
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany rkoller Nรผrnberg, Germany
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany rkoller Nรผrnberg, Germany

    the following issue ๐Ÿ› Wrong DRUPAL_ROOT with non-standard code structure RTBC might be also relevant for drupal sites in production as soon as it gets committed?

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom joachim

    If I understand it correctly, the problem is that Project Browser creates a temporary Composer project in a temporary folder, using a copy of the project's composer.json file.

    In joachim-n/drupal-core-development-project, Drupal core is coming from a Composer path repository, which is declared in composer.json with a relative path.

    So I think this problem will happen if there are *any* Composer path repositories -- e.g. with https://github.com/joachim-n/drupal-project-contrib-development, or if there are any other packages being used like that.

    I don't think ๐Ÿ› Wrong DRUPAL_ROOT with non-standard code structure RTBC is relevant here, as that is to do with fixing Drupal core so it works properly when using a path repository.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom joachim

    If I'm right about the problem, then the fix would be for the process that copies the project's composer.json file to check the 'repositories' property for any repos which are path repos, check those for any relative paths, and the prefix the absolute directory path of the project to that URL in the temporary copy.

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany rkoller Nรผrnberg, Germany

    The issue can be fixed by applying the following command according to @chrisfromredfin ddev drush cset -y package_manager.settings include_unknown_files_in_project_root true, I think it is ok deliberately enabling including unknown files found in the project root and not making it automatically working per default.
    but i see another problem then here. it is not clear at all based on the error message in the issue summary what the actual problem is and how to fix it. Instead of labeling it with "StageException: Failed to run process" and providing a cryptic cmd line output, how about explain what is actually happening instead, that some unknown files/directories are included in the project root and that is the reason why the install fails (include one or two examples)? and provide the drush command how to enable those unknown files to the user as well: ddev drush cset -y package_manager.settings include_unknown_files_in_project_root true. that would be way more clear and directly actionable.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom joachim

    > ddev drush cset -y package_manager.settings include_unknown_files_in_project_root true

    I presume that copies over any files from the project root over into the staging project? If there is a clone of Drupal core in repos/drupal, then that's a LOT of files to copy!

    I think amending the path repo to point to the same place would be simpler and quicker!

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States phenaproxima Massachusetts

    This is because Package Manager ignores any unrecognized files/dirs in the project root.

    The workaround is to set package_manager.settings:include_unknown_files_in_project_root (config flag) to true.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States phenaproxima Massachusetts

    Re #7: I agree, but that's not something Package Manager is willing to do :) If you change the path repos in composer.json to use absolute paths instead of relative paths, that would probably fix the problem without needing to change that Package Manager setting.

Production build 0.71.5 2024