Composer.json deletes dir even with preserve path I am running composer on Drupal 7 and I am just trying to update my site; however when I run composer update, the composer deletes all the preserve paths I had specified.

My structure is as follows:

composer.json

composer.lock

web/

    -sites/default


in my composer.json I have as follow:

{
...
"repositories": [
    {
        "type": "composer",
        "url": "https://packages.drupal.org/7"
    }
],
"require": {
   ...
},
"conflict": {
    "drupal/core": "8.*"
},
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
      "sort-packages": true
},
"autoload": {
    "classmap": [
        "scripts/composer/ScriptHandler.php"
    ]
},
"scripts": {
    "pre-install-cmd": [
        "DrupalProject\\composer\\ScriptHandler::checkComposerVersion"
    ],
    "pre-update-cmd": [
        "DrupalProject\\composer\\ScriptHandler::checkComposerVersion"
    ],
    "post-install-cmd": [
        "DrupalProject\\composer\\ScriptHandler::createRequiredFiles"
    ],
    "post-update-cmd": [
        "DrupalProject\\composer\\ScriptHandler::createRequiredFiles"
    ],
    "post-create-project-cmd": [
        "DrupalProject\\composer\\ScriptHandler::removeInternalFiles"
    ]
},
"extra": {
    "installer-paths": {
        "web/": ["type:drupal-core"],
        "web/profiles/{$name}/": ["type:drupal-profile"],
        "web/sites/all/drush/{$name}/": ["type:drupal-drush"],
        "web/sites/all/libraries/{$name}/": ["type:drupal-library"],
        "web/sites/all/modules/contrib/{$name}/": ["type:drupal-module"],
        "web/sites/all/themes/contrib/{$name}/": ["type:drupal-theme"]
    },
    "patches": {
        "cweagans/composer-patches": {
            "Call the preserve paths hooks" : "https://github.com/SebCorbin/composer-patches/commit/1cb9bacba51f8bba0c5f3f322c3bb61e4ceae974.patch"
        }
    },
    "preserve-paths": [
        "web/sites/all/drush",
        "web/sites/all/libraries",
        "web/sites/all/modules/contrib",
        "web/sites/all/modules/custom",
        "web/sites/all/modules/features",
        "web/sites/all/themes/contrib",
        "web/sites/all/themes/custom",
        "web/sites/all/translations",
        "web/sites/default"
    ]
}


}

What ends up happening is it install the core and modules correctly in web/ folder, but deletes all the preserve paths as well. Any suggestions as to why i am having this problem? Thank you.

I have tried to put composer.json in the web/ folder as well, that just imports all the require modules and core in a subfolder (web/web/).

I am now getting:

Files of installed package were overwritten with preserved path x/web/sites/default!

Files of installed package were overwritten with preserved path x/web/sites/all/libraries!

and the preserve paths didn't do anything.
It looks like you haven't installed the plugin. Just run:

composer require drupal-composer/preserve-paths


And try again.

If it still doesn't work, you'll probably need to report it as a bug to the plugin's issue queue.