简体   繁体   English

为什么 Drupal 的作曲家创建项目在 WSL2 中失败?

[英]Why does composer create-project for Drupal fail in WSL2?

I am a Drupal site builder experimenting with WSL2 and I am finding the routine creating a Drupal project with composer does not complete.我是一名 Drupal 站点构建者,正在试验 WSL2,我发现使用 composer 创建 Drupal 项目的例程没有完成。

My PC has 16GB RAM and composer is allowed unlimited memory.我的 PC 有 16GB RAM,并且允许作曲家无限 memory。 To the best of my understanding I have Docker configured correctly for WSL2.据我了解,我已为 WSL2 正确配置了 Docker。

The create-project process starts normally but then stalls when installing drupal/core (9.0.2).创建项目过程正常启动,但在安装 drupal/core (9.0.2) 时停止。 This appears to be so whether downloading from source or from cache.无论是从源下载还是从缓存下载,这似乎都是如此。 After a considerable time the process will fail.相当长的时间后,该过程将失败。 The contents of the project folder are largely incomplete.项目文件夹的内容大部分不完整。

I first attempted this with a Drupal 9 recipe for DDEV , a container based local dev environment which includes composer.我首先尝试使用 DDEV 的Drupal 9 配方,这是一个基于容器的本地开发环境,其中包括作曲家。

Not wishing to point the finger at DDEV, I then installed composer via Homebrew in the Home directory of WSL2 and tried again, independently of DDEV or Docker.不希望将矛头指向 DDEV,然后我通过 Homebrew 在 WSL2 的主目录中安装了 composer 并再次尝试,独立于 DDEV 或 Docker。 After running composer create-project drupal/recommended-project my_site_name_dir I find that composer fails in exactly the same way.运行composer create-project drupal/recommended-project my_site_name_dir ,我发现 composer 以完全相同的方式失败。

Composer output follows;作曲家 output 如下;

paul@DESKTOP-TQA1I7L:/mnt/c/Users/Paul/Sites/D9$ composer create-project drupal/recommended-project my_site_name_dir Creating a "drupal/recommended-project" project at "./my_site_name_dir" Installing drupal/recommended-project (9.0.2) paul@DESKTOP-TQA1I7L:/mnt/c/Users/Paul/Sites/D9$ composer create-project drupal/recommended-project my_site_name_dir 在 "./my_site_name_dir" 创建一个 "drupal/recommended-project" 项目 安装 drupal/recommended-项目 (9.0.2)

  • Installing drupal/recommended-project (9.0.2): Loading from cache Created project in /mnt/c/Users/Paul/Sites/D9/my_site_name_dir Loading composer repositories with package information Installing dependencies (including require-dev) from lock file Package operations: 59 installs, 0 updates, 0 removals安装 drupal/recommended-project (9.0.2):从缓存中加载 在 /mnt/c/Users/Paul/Sites/D9/my_site_name_dir 中创建项目 使用 package 信息加载作曲家存储库 从锁定文件 Z209802FB858E2C832Z5027E 安装依赖项(包括 require-dev)操作:59 次安装、0 次更新、0 次删除
  • Installing composer/installers (v1.9.0): Loading from cache安装作曲家/安装程序(v1.9.0):从缓存加载
  • Installing drupal/core-composer-scaffold (9.0.2): Loading from cache安装 drupal/core-composer-scaffold (9.0.2):从缓存加载
  • Installing drupal/core-project-message (9.0.2): Loading from cache安装 drupal/core-project-message (9.0.2):从缓存加载
  • Installing typo3/phar-stream-wrapper (v3.1.4): Loading from cache安装typo3/phar-stream-wrapper (v3.1.4):从缓存加载
  • Installing symfony/polyfill-mbstring (v1.17.0): Loading from cache安装 symfony/polyfill-mbstring (v1.17.0):从缓存加载
  • Installing symfony/polyfill-ctype (v1.17.0): Loading from cache安装 symfony/polyfill-ctype (v1.17.0):从缓存加载
  • Installing twig/twig (v2.12.5): Loading from cache安装 twig/twig (v2.12.5):从缓存加载
  • Installing symfony/yaml (v4.4.9): Loading from cache安装 symfony/yaml (v4.4.9):从缓存加载
  • Installing symfony/polyfill-php80 (v1.17.0): Loading from cache安装 symfony/polyfill-php80 (v1.17.0):从缓存加载
  • Installing symfony/var-dumper (v5.1.0): Loading from cache安装 symfony/var-dumper (v5.1.0):从缓存加载
  • Installing symfony/translation-contracts (v2.1.2): Loading from cache安装 symfony/translation-contracts (v2.1.2):从缓存加载
  • Installing symfony/validator (v4.4.9): Loading from cache安装 symfony/validator (v4.4.9):从缓存加载
  • Installing symfony/translation (v4.4.9): Loading from cache安装 symfony/translation (v4.4.9):从缓存加载
  • Installing psr/container (1.0.0): Loading from cache安装 psr/container (1.0.0):从缓存加载
  • Installing symfony/service-contracts (v2.1.2): Loading from cache安装 symfony/service-contracts (v2.1.2):从缓存加载
  • Installing symfony/serializer (v4.4.9): Loading from cache安装 symfony/serializer (v4.4.9):从缓存加载
  • Installing symfony/routing (v4.4.9): Loading from cache安装 symfony/routing (v4.4.9): 从缓存加载
  • Installing symfony/polyfill-php72 (v1.17.0): Loading from cache安装 symfony/polyfill-php72 (v1.17.0):从缓存加载
  • Installing symfony/polyfill-intl-idn (v1.17.0): Loading from cache安装 symfony/polyfill-intl-idn (v1.17.0):从缓存加载
  • Installing symfony/mime (v5.1.0): Loading from cache安装 symfony/mime (v5.1.0):从缓存加载
  • Installing symfony/http-foundation (v4.4.9): Loading from cache安装 symfony/http-foundation (v4.4.9):从缓存加载
  • Installing psr/http-message (1.0.1): Loading from cache安装 psr/http-message (1.0.1):从缓存加载
  • Installing symfony/psr-http-message-bridge (v2.0.0): Loading from cache安装 symfony/psr-http-message-bridge (v2.0.0):从缓存加载
  • Installing symfony/process (v4.4.9): Loading from cache安装 symfony/process (v4.4.9):从缓存加载
  • Installing symfony/polyfill-php73 (v1.17.0): Loading from cache安装 symfony/polyfill-php73 (v1.17.0):从缓存加载
  • Installing symfony/polyfill-iconv (v1.17.0): Loading from cache安装 symfony/polyfill-iconv (v1.17.0):从缓存加载
  • Installing symfony/event-dispatcher-contracts (v1.1.7): Loading from cache安装 symfony/event-dispatcher-contracts (v1.1.7):从缓存加载
  • Installing symfony/event-dispatcher (v4.4.9): Loading from cache安装 symfony/event-dispatcher (v4.4.9):从缓存加载
  • Installing psr/log (1.1.3): Loading from cache安装 psr/log (1.1.3):从缓存加载
  • Installing symfony/debug (v4.4.9): Loading from cache安装 symfony/debug (v4.4.9):从缓存加载
  • Installing symfony/error-handler (v4.4.9): Loading from cache安装 symfony/error-handler (v4.4.9):从缓存加载
  • Installing symfony/http-kernel (v4.4.9): Loading from cache安装 symfony/http-kernel (v4.4.9):从缓存加载
  • Installing symfony/dependency-injection (v4.4.9): Loading from cache安装 symfony/dependency-injection (v4.4.9):从缓存加载
  • Installing symfony/console (v4.4.9): Loading from cache安装 symfony/console (v4.4.9):从缓存加载
  • Installing symfony-cmf/routing (2.3.2): Loading from cache安装 symfony-cmf/routing (2.3.2):从缓存加载
  • Installing stack/builder (v1.0.6): Loading from cache安装堆栈/构建器(v1.0.6):从缓存加载
  • Installing ralouphie/getallheaders (3.0.3): Loading from cache安装 ralouphie/getallheaders (3.0.3):从缓存加载
  • Installing psr/http-factory (1.0.1): Loading from cache安装 psr/http-factory (1.0.1):从缓存加载
  • Installing pear/pear_exception (v1.0.1): Loading from cache安装 pear/pear_exception (v1.0.1):从缓存加载
  • Installing pear/console_getopt (v1.4.3): Loading from cache安装 pear/console_getopt (v1.4.3):从缓存加载
  • Installing pear/pear-core-minimal (v1.10.10): Loading from cache安装 pear/pear-core-minimal (v1.10.10):从缓存加载
  • Installing pear/archive_tar (1.4.9): Loading from cache安装 pear/archive_tar (1.4.9):从缓存加载
  • Installing masterminds/html5 (2.7.0): Loading from cache安装 masterminds/html5 (2.7.0):从缓存加载
  • Installing laminas/laminas-zendframework-bridge (1.0.4): Loading from cache安装 laminas/laminas-zendframework-bridge (1.0.4):从缓存加载
  • Installing laminas/laminas-stdlib (3.2.1): Loading from cache安装 laminas/laminas-stdlib (3.2.1):从缓存加载
  • Installing laminas/laminas-escaper (2.6.1): Loading from cache安装 laminas/laminas-escaper (2.6.1):从缓存加载
  • Installing laminas/laminas-feed (2.12.2): Loading from cache安装 laminas/laminas-feed (2.12.2):从缓存加载
  • Installing laminas/laminas-diactoros (2.3.0): Loading from cache安装 laminas/laminas-diactoros (2.3.0):从缓存加载
  • Installing guzzlehttp/psr7 (1.6.1): Loading from cache安装 guzzlehttp/psr7 (1.6.1):从缓存加载
  • Installing guzzlehttp/promises (v1.3.1): Loading from cache安装 guzzlehttp/promises (v1.3.1):从缓存加载
  • Installing guzzlehttp/guzzle (6.5.4): Loading from cache安装 guzzlehttp/guzzle (6.5.4):从缓存加载
  • Installing doctrine/lexer (1.2.1): Loading from cache安装学说/词法分析器(1.2.1):从缓存加载
  • Installing egulias/email-validator (2.1.17): Loading from cache安装 egulias/email-validator (2.1.17):从缓存加载
  • Installing doctrine/annotations (1.10.3): Loading from cache安装学说/注释(1.10.3):从缓存加载
  • Installing doctrine/reflection (1.2.1): Loading from cache安装学说/反射(1.2.1):从缓存加载
  • Installing composer/semver (1.5.1): Loading from cache安装 composer/semver (1.5.1): 从缓存加载
  • Installing asm89/stack-cors (1.3.0): Loading from cache安装 asm89/stack-cors (1.3.0):从缓存加载
  • Installing drupal/core (9.0.2): Loading from cache Failed to download drupal/core from dist: Could not delete /mnt/c/Users/Paul/Sites/D9/my_site_name_dir/vendor/composer/782129de/drupal-core-ea6e0ce/lib/Drupal/Core: Now trying to download from source安装drupal/core(9.0.2):从缓存加载无法从dist下载drupal/core:无法删除/mnt/c/Users/Paul/Sites/D9/my_site_name_dir/vendor/composer/782129de/drupal-core- ea6e0ce/lib/Drupal/Core:现在尝试从源下载
  • Installing drupal/core (9.0.2): Cloning ea6e0cef32 from cache安装 drupal/core (9.0.2):从缓存中克隆 ea6e0cef32

[Symfony\Component\Process\Exception\ProcessTimedOutException] The process "git checkout '9.0.2' --" exceeded the timeout of 300 seconds. [Symfony\Component\Process\Exception\ProcessTimedOutException] 进程“git checkout '9.0.2' --”超过了 300 秒的超时时间。

create-project [-s|--stability STABILITY] [--prefer-source] [--prefer-dist] [--repository REPOSITORY] [--repository-url REPOSITORY-URL] [--add-repository] [--dev] [--no-dev] [--no-custom-installers] [--no-scripts] [--no-progress] [--no-secure-http] [--keep-vcs] [--remove-vcs] [--no-install] [--ignore-platform-reqs] [--] [] [] [] create-project [-s|--stability STABILITY] [--prefer-source] [--prefer-dist] [--repository REPOSITORY] [--repository-url REPOSITORY-URL] [--add-repository] [ --dev] [--no-dev] [--no-custom-installers] [--no-scripts] [--no-progress] [--no-secure-http] [--keep-vcs] [--remove-vcs] [--no-install] [--ignore-platform-reqs] [--] [] [] []

paul@DESKTOP-TQA1I7L:/mnt/c/Users/Paul/Sites/D9$ paul@DESKTOP-TQA1I7L:/mnt/c/Users/Paul/Sites/D9$ composer create-project drupal/recommended-project my_site_name_dir Creating a "drupal/recommended-project" project at "./my_site_name_dir" paul@DESKTOP-TQA1I7L:/mnt/c/Users/Paul/Sites/D9$ paul@DESKTOP-TQA1I7L:/mnt/c/Users/Paul/Sites/D9$ composer create-project drupal/recommended-project my_site_name_dir 创建一个“./my_site_name_dir”中的“drupal/recommended-project”项目

[InvalidArgumentException] Project directory "/mnt/c/Users/Paul/Sites/D9/my_site_name_dir" is not empty. [InvalidArgumentException] 项目目录“/mnt/c/Users/Paul/Sites/D9/my_site_name_dir”不为空。

create-project [-s|--stability STABILITY] [--prefer-source] [--prefer-dist] [--repository REPOSITORY] [--repository-url REPOSITORY-URL] [--add-repository] [--dev] [--no-dev] [--no-custom-installers] [--no-scripts] [--no-progress] [--no-secure-http] [--keep-vcs] [--remove-vcs] [--no-install] [--ignore-platform-reqs] [--] [] [] [] create-project [-s|--stability STABILITY] [--prefer-source] [--prefer-dist] [--repository REPOSITORY] [--repository-url REPOSITORY-URL] [--add-repository] [ --dev] [--no-dev] [--no-custom-installers] [--no-scripts] [--no-progress] [--no-secure-http] [--keep-vcs] [--remove-vcs] [--no-install] [--ignore-platform-reqs] [--] [] [] []

You absolutely need to put your project on the WSL2 filesystem for decent performance, yes.您绝对需要将您的项目放在 WSL2 文件系统上以获得良好的性能,是的。 See @MrPaulDriver answer, absolutely critical.请参阅@MrPaulDriver 的回答,绝对关键。

But we recommend using ddev composer everywhere.但我们建议在任何地方都使用ddev composer That makes your composer build using the same composer settings and php version that your project runs with, and it helps most people.这使您的作曲家使用与您的项目运行相同的作曲家设置和 php 版本进行构建,它可以帮助大多数人。 It's not even required to install php or composer on the host of a ddev host computer because of this.因此,甚至不需要在 ddev 主机的主机上安装 php 或 composer。

For example, the Drupal 9 Quickstart shows例如, Drupal 9 快速入门显示

mkdir my-drupal9-site
cd my-drupal9-site
ddev config --project-type=drupal9 --docroot=web --create-docroot
ddev start
ddev composer create "drupal/recommended-project"
ddev composer require drush/drush
ddev launch

I imagine this would have worked for you even in your previous setup;我想即使在您以前的设置中,这也对您有用; it's worked loads of places.它在很多地方都有效。

For more detail, please take a look at DDEV and Composer in the docs.有关更多详细信息,请查看文档中的DDEV 和 Composer

After reading some updated documentation I now understand the problem was that I was attempting to perform this operation under the Windows file system at .mnt/c/Users/Paul instead of the Linux location of /home/paul在阅读了一些更新的文档后,我现在明白问题是我试图在.mnt/c/Users/Paul的 Windows 文件系统下执行此操作,而不是/home/paul的 Linux 位置

As well as completing without errors, performance is vastly improved.除了没有错误地完成之外,性能也大大提高。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM