When I install a new module, I run...
composer require drupal/module_name

That works. But it always overwrites this part of my development.services.yml...

parameters:
  twig.config:
    debug: true
    auto_reload: true
    cache: false

Do I need to have that info somewhere else? Am I doing something wrong?

Comments

xpersonas’s picture

Man, I too want to know the answer to this question. Sorry to see this was never answered.

bjlewis2’s picture

The drupal-scaffold that comes with the drupal-composer/drupal-project starter includes this file in its scaffolding scripts, so it gets written every time you composer-install or something of the sort.

I was able to fix this by adding the path to the "excludes" section like so:

        "drupal-scaffold": {
            "source": "https://raw.githubusercontent.com/pantheon-systems/drops-8-scaffolding/{version}/{path}",
            "includes": [
                "sites/default/default.services.pantheon.preproduction.yml",
                "sites/default/settings.pantheon.php"
            ],
            "excludes": [
                ".csslintrc",
                ".editorconfig",
                ".eslintignore",
                ".eslintrc.json",
                ".htaccess",
                "web.config",
                "sites/development.services.yml"
            ]
        },

Now, it no longer overwrites that file.

Hope that helps!

ultrabob’s picture

Just to stop overwriting that single file, all you need to add into the extras section is this:

"drupal-scaffold": {
    "excludes": [
        "sites/development.services.yml"
    ]
},
xpersonas’s picture

FWIW, the exclude key worked for a while, but no longer works for me. This is what I have now and seems to be doing the trick...

"drupal-scaffold": {
    "file-mapping": {
        "[web-root]/sites/development.services.yml": false
    }
}
Joe Huggans’s picture

This worked for me with the drupal/recommended-project composer project.

You can confirm this works when running composer update /install and it should print out the following -

Scaffolding files for drupal/recommended-project:
  - Skip [web-root]/sites/development.services.yml: disabled

ultrabob’s picture

Are you using the new recommended project Drupal composer project?  The above still works for me for composer/drupal-project. 

xpersonas’s picture

Yes I believe so...

"drupal/core": "^8.8.0",
"drupal/core-composer-scaffold": "^8.8",
ultrabob’s picture

Ok, good so now we have instructions for how to do it on the Drupal core recommended composer project, and on the previously commonly used setup. 

mmjvb’s picture

after initial use. It doesn't do the right things as you discovered. Unfortunately, the right thing is not a universal truth. It is depending on your circumstances what needs to be done. Rather than doing the wrong things most of the time, it should inform you that you need to do something. Currently, you need to detect that yourself.

For each of the files involved in scaffolding you need to determine your own version control. You need to decide what to do when changes occur. For some of those files it is fine to blindly accept the changes. For others you need to combine yours with their changes. Still others require you to apply changes to files based on that file.

Simply ignoring the changes for that file is just as bad as simply accepting the changes. Essentially, you need to be informed about the change and decide what to do. And you are the only one that can determine the right thing to do.

ultrabob’s picture

Agreed,I think the scaffolding in the core project does a lot more that I don’t like than the old composer project, but I’d rather it all only run once, or produce output telling you where to look to figure out how to turn those things off. I think that conversation is actively happening for the core project. 

mmjvb’s picture

because the files are now also part of core. Makes it easier to do the things properly. Allowing for three way merge.

borutpiletic’s picture

Renaming the development.services.yml file in your settings.local.php should do the trick. I would not exclude the file completely, since it will be missing if the project is installed elsewhere.

$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/local.development.services.yml';
robert_t_taylor’s picture

This worked for me and seemed less likely to cause issues later. Thanks all for the solutions; I tried a few before settling on @borutpiletic's