【问题标题】:Installation failed - trying to install modules on Drupal8 using composer安装失败 - 尝试使用 composer 在 Drupal8 上安装模块
【发布时间】:2021-01-25 23:06:57
【问题描述】:

因此,对于我尝试在我的 drupal8 环境中安装的任何模块,我都会收到相同的错误消息。 我一直在移动文件和文件夹,所以我确定我弄坏了一些东西。

我是否可以在 drupal 日志文件中查找有关错误的更多帮助,或者有人知道此错误的原因吗?

composer require drupal/Astrology
Using version ^1.4 for drupal/astrology
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing drupal/astrology (1.4.0): Loading from cache
Package container-interop/container-interop is abandoned, you should avoid using it. Use psr/container instead.
Writing lock file
Generating autoload files
29 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

Installation failed, reverting ./composer.json to its original content.

                                            
  [RuntimeException]                        
  does not exist and could not be created.  
                                            

这是完整的 composer.json 文件:

{
    "name": "drupal/recommended-project",
    "description": "Project template for Drupal 8 projects with a relocated document root",
    "type": "project",
    "license": "GPL-2.0-or-later",
    "homepage": "https://www.drupal.org/project/drupal",
    "support": {
        "docs": "https://www.drupal.org/docs/user_guide/en/index.html",
        "chat": "https://www.drupal.org/node/314178"
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        }
    ],
    "require": {
        "composer/installers": "^1.2",
        "drupal/admin_toolbar": "^2.3",
        "drupal/bootstrap_barrio": "^5.1",
        "drupal/coffee": "^1.0",
        "drupal/core-composer-scaffold": "^8.8",
        "drupal/core-project-message": "^8.8",
        "drupal/core-recommended": "^8.8",
        "drupal/devel": "^4.0",
        "drupal/entity_delete": "^1.6",
        "drupal/feeds": "^3.0@alpha",
        "drupal/feeds_tamper": "^2.0@beta",
        "drupal/flexslider_fields": "^2.0",
        "drupal/fontawesome": "^2.17",
        "drupal/gdoc_field": "^1.1",
        "drupal/migrate_plus": "^5.1",
        "drupal/migrate_tools": "^5.0",
        "drupal/migrate_upgrade": "^3.2",
        "drupal/paragraphs": "^1.12",
        "drupal/pathauto": "^1.8",
        "drupal/pdf_reader": "1.x-dev",
        "drupal/superfish": "^1.4",
        "drupal/tablefield": "^2.1",
        "drush/drush": "^10.3"
    },
    "conflict": {
        "drupal/drupal": "*"
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "config": {
        "sort-packages": true
    },
    "extra": {
        "drupal-scaffold": {
            "locations": {
                "web-root": ""
            }
        },
        "installer-paths": {
            "core": [
                "type:drupal-core"
            ],
            "libraries/{$name}": [
                "type:drupal-library"
            ],
            "modules/contrib/{$name}": [
                "type:drupal-module"
            ],
            "profiles/contrib/{$name}": [
                "type:drupal-profile"
            ],
            "themes/contrib/{$name}": [
                "type:drupal-theme"
            ],
            "drush/Commands/contrib/{$name}": [
                "type:drupal-drush"
            ],
            "modules/custom/{$name}": [
                "type:drupal-custom-module"
            ],
            "themes/custom/{$name}": [
                "type:drupal-custom-theme"
            ]
        },
        "drupal-core-project-message": {
            "include-keys": [
                "homepage",
                "support"
            ],
            "post-create-project-cmd-message": [
                "<bg=blue;fg=white>                                                         </>",
                "<bg=blue;fg=white>  Congratulations, you’ve installed the Drupal codebase  </>",
                "<bg=blue;fg=white>  from the drupal/recommended-project template!          </>",
                "<bg=blue;fg=white>                                                         </>",
                "",
                "<bg=yellow;fg=black>Next steps</>:",
                "  * Install the site: https://www.drupal.org/docs/8/install",
                "  * Read the user guide: https://www.drupal.org/docs/user_guide/en/index.html",
                "  * Get support: https://www.drupal.org/support",
                "  * Get involved with the Drupal community:",
                "      https://www.drupal.org/getting-involved",
                "  * Remove the plugin that prints this message:",
                "      composer remove drupal/core-project-message"
            ]
        }
    }
}

谢谢 标记

【问题讨论】:

  • 你能发布完整的 composer.json 文件吗?
  • @RadosławHalicki 我现在已经添加了。最初文档根目录位于“web”文件夹中,但我将其移回了根目录,所以我想知道这是否与它有关。

标签: composer-php drupal-8


【解决方案1】:

您的问题有一个简单的解决方案。添加网络根文件夹。公平地说,将供应商存储在 Web 文件夹之外是一种很好的做法。

这里是你应该如何做的例子(你也可以将 web 更改为 docroot 或任何你喜欢的东西):

    "extra": {
    "drupal-scaffold": {
        "locations": {
            "web-root": "./web"
        }
    },
    "installer-paths": {
        "web/core": [
            "type:drupal-core"
        ],
        "web/libraries/{$name}": [
            "type:drupal-library"
        ],
        "web/modules/contrib/{$name}": [
            "type:drupal-module"
        ],
        "web/profiles/contrib/{$name}": [
            "type:drupal-profile"
        ],
        "web/themes/contrib/{$name}": [
            "type:drupal-theme"
        ],
        "drush/Commands/contrib/{$name}": [
            "type:drupal-drush"
        ],
        "web/modules/custom/{$name}": [
            "type:drupal-custom-module"
        ],
        "web/themes/custom/{$name}": [
            "type:drupal-custom-theme"
        ]
    },

您可能注意到 drush 命令位于 web 文件夹之外。与存储构建脚本、服务器挂钩、补丁等的方式相同。

【讨论】:

  • 是的,这有效(当我在本地运行时)。我将文件从“web”文件夹移动到根目录,因为在我们的托管服务器上,它只有在文件存在时才有效。明天我会提出一个单独的问题,因为我确定我肯定遗漏了一些简单的东西。
  • 这个答案可能应该注意到这些设置是在recommended-project 中使用的,这是Using Composer to Install Drupal and Manage Dependencies 文档中的引用
  • 公平地说,我建议更改服务器设置以使用 web-root 文件夹。这就是两个最好的 Drupal 主机 - Acquia 和 Pantheon 的工作方式。如果没有,我也会尝试在没有根文件夹的情况下解决它。
猜你喜欢
  • 2020-02-21
  • 2014-04-09
  • 1970-01-01
  • 1970-01-01
  • 2021-08-10
  • 2017-11-22
  • 2021-05-25
  • 1970-01-01
  • 2014-04-12
相关资源
最近更新 更多