Score:0

Composer modified installation with changed /web reference in composer.json fails

na flag

Based on this question.

I am running a modified composer installation.

composer create-project --no-install drupal/recommended-project ./

I am changing "web" in the composer.json like so:

{
"name": "drupal/recommended-project",
"description": "Project template for Drupal 9 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.9",
    "drupal/core-composer-scaffold": "^9.5",
    "drupal/core-project-message": "^9.5",
    "drupal/core-recommended": "^9.5"
},
"conflict": {
    "drupal/drupal": "*"
},
"minimum-stability": "stable",
"prefer-stable": true,
"config": {
    "allow-plugins": {
        "composer/installers": true,
        "drupal/core-composer-scaffold": true,
        "drupal/core-project-message": true,
        "dealerdirect/phpcodesniffer-composer-installer": true
    },
    "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"
        ],
        "/profiles/custom/{$name}": [
            "type:drupal-custom-profile"
        ],
        "/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/installing-drupal",
            "  * 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"
        ]
    }
}
}

And when I run composer install

I get errors similar to this:

file_put_contents(//.csslintrc): failed to open stream: Read-only file system

NOTE: Running a normal composer installation, installs normally with no issues:

composer create-project drupal/recommended-project ./

I have also tried composer update after the changes in composer.json, but I get the same issue.

Thanks

4uk4 avatar
cn flag
Don't use the recommended project to remove the subfolder. Even if you get it working this is a security risk. See my answer to the previous question https://drupal.stackexchange.com/a/315089/47547
apaderno avatar
us flag
`web-root` is not /, but the server document root directory as set in the server configuration. Neither the answers given in the previous question said to use / as server document root directory.
4uk4 avatar
cn flag
The suggestion in my answer is to use a different composer project. This has the desired result: https://github.com/drupal/legacy-project/blob/10.0.5/composer.json#L43
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.