Score:0

Composer Remove leaves files and references in composer.lock

gg flag

I'm trying to update my site from D8 to D9 and there are a few modules I no longer need and am trying to get rid of. I run composer remove drupal/varbase_core and it removes it from my composer.json, but leaves several references in composer.lock. I look in the file system and the files are still there and the next time I run composer update, the files are restored.

How can I actually get rid of these modules?

Thanks!

My composer.json file:

{
    "name": "pantheon-systems/example-drops-8-composer",
    "description": "Install drops-8 with Composer on Pantheon.",
    "type": "project",
    "license": "MIT",
    "repositories": [
        {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        },
        {
            "type": "package",
            "package": {
                "name": "google/charts",
                "version": "45",
                "type": "drupal-library",
                "extra": {
                    "installer-name": "google_charts"
                },
                "dist": {
                    "url": "https://www.gstatic.com/charts/loader.js",
                    "type": "file"
                },
                "require": {
                    "composer/installers": "~1.0"
                }
            }
        }
    ],
    "require": {
        "php": ">=7.2.0",
        "composer/installers": "^1.0.20",
        "cweagans/composer-patches": "^1.0",
        "drupal-composer/drupal-scaffold": "^2.0.1",
        "drupal/admin_toolbar": "^2.0",
        "drupal/adminimal_admin_toolbar": "^1.8",
        "drupal/adminimal_theme": "^1.3",
        "drupal/advanced_text_formatter": "^2.0",
        "drupal/anchor_link": "^1.6",
        "drupal/auto_entitylabel": "^3.0@beta",
        "drupal/autocomplete_deluxe": "^2.0@alpha",
        "drupal/backup_migrate": "^5.0",
        "drupal/better_exposed_filters": "^5.0@alpha",
        "drupal/better_normalizers": "^1.0@beta",
        "drupal/betterlogin": "^1.4",
        "drupal/block_class": "^1.0",
        "drupal/bootstrap_layouts": "^5.1",
        "drupal/cache_control_override": "^1.0@alpha",
        "drupal/captcha": "^1.0",
        "drupal/charts": "^3.2",
        "drupal/checklistapi": "^1.11",
        "drupal/ckeditor_media_embed": "^1.6",
        "drupal/classy_paragraphs": "1.x-dev",
        "drupal/color_field": "^2.2",
        "drupal/colorbox": "^1.4",
        "drupal/colorbox_inline": "^1.2",
        "drupal/commerce": "^2.9",
        "drupal/commerce_authnet": "^1.0",
        "drupal/commerce_product": "^2.25",
        "drupal/commerce_product_bundle": "^1.0@alpha",
        "drupal/commerce_shipping": "^2.0@beta",
        "drupal/components": "^2.4",
        "drupal/config_direct_save": "^1.0",
        "drupal/config_filter": "^1.5",
        "drupal/config_ignore": "^2.2",
        "drupal/config_split": "^1.4",
        "drupal/config_update": "^1.7",
        "drupal/console": "^1",
        "drupal/content_lock": "^2.0",
        "drupal/core": "^8.7.10",
        "drupal/core-recommended": "^8",
        "drupal/createandcontinue": "^1.2",
        "drupal/crop": "2.0.0",
        "drupal/datatables": "^2.0",
        "drupal/date_popup": "^1.1",
        "drupal/default_content": "^1.0@alpha",
        "drupal/devel_entity_updates": "^3.0",
        "drupal/domain": "^1.0@alpha",
        "drupal/domain_entity": "^1.0@alpha",
        "drupal/domain_site_settings": "^1.3",
        "drupal/drd_agent": "^3.13",
        "drupal/dropzonejs_eb_widget": "^2.0@alpha",
        "drupal/ds": "^3.5",
        "drupal/empty_fields": "^1.0@alpha",
        "drupal/entity_browser": "^2.0",
        "drupal/entity_browser_enhanced": "^1.0@RC",
        "drupal/entity_browser_entity_form": "*",
        "drupal/entity_browser_generic_embed": "*",
        "drupal/entity_clone": "^1.0@beta",
        "drupal/entity_embed": "^1.0",
        "drupal/entity_usage": "^2.0@alpha",
        "drupal/entityqueue_form_widget": "^2.0",
        "drupal/features": "^3.8",
        "drupal/field_group": "3.x-dev",
        "drupal/fitvids": "^1.0",
        "drupal/focal_point": "^1.0@beta",
        "drupal/form_mode_manager": "^2.0",
        "drupal/genpass": "^1.0",
        "drupal/geocoder": "^3.11",
        "drupal/google_analytics": "^3.0",
        "drupal/hierarchical_term_formatter": "^1.1",
        "drupal/hreflang": "^1.3",
        "drupal/ief_table_view_mode": "^2.0@beta",
        "drupal/image_widget_crop": "^2.2",
        "drupal/layout_builder_modal": "^1.0",
        "drupal/layout_builder_restrictions": "^2.6",
        "drupal/length_indicator": "^1.1",
        "drupal/libraries": "^3.0@alpha",
        "drupal/link_attributes": "^1.10",
        "drupal/linkit": "5.x-dev@dev",
        "drupal/login_destination": "^2.0@beta",
        "drupal/login_security": "^2.0",
        "drupal/mandrill": "^1.1",
        "drupal/masquerade": "^2.0@beta",
        "drupal/material_base": "^1.8",
        "drupal/maxlength": "^1.0@beta",
        "drupal/menu_admin_per_menu": "^1.0",
        "drupal/menu_block": "^1.5",
        "drupal/menu_link_attributes": "^1.0",
        "drupal/menu_position": "^1.0@alpha",
        "drupal/metatag": "^1.7",
        "drupal/migrate_source_csv": "^3.4",
        "drupal/migrate_tools": "^4.1",
        "drupal/node_edit_protection": "^1.0@alpha",
        "drupal/page_manager": "^4.0@beta",
        "drupal/panels": "^4.6",
        "drupal/paragraphs": "^1.3",
        "drupal/paragraphs_edit": "^2.0@alpha",
        "drupal/password_policy": "^3.0@beta",
        "drupal/pathauto": "^1.2",
        "drupal/pathologic": "^1.0@alpha",
        "drupal/permissions_filter": "^1.1",
        "drupal/persistent_login": "^1.1",
        "drupal/r4032login": "^2.1",
        "drupal/rabbit_hole": "^1.0@beta",
        "drupal/recaptcha": "^3.0",
        "drupal/redirect": "^1.6",
        "drupal/responsive_preview": "^1.0@beta",
        "drupal/revision_log_default": "^1.1",
        "drupal/roleassign": "^1.0@beta",
        "drupal/rules": "3.0-alpha7",
        "drupal/search_api": "^1.9",
        "drupal/search_api_db": "^1.9",
        "drupal/seckit": "^2.0",
        "drupal/security_review": "^1.0@alpha",
        "drupal/shield": "^1.4",
        "drupal/simple_block": "^1.0@beta",
        "drupal/simple_sitemap": "^3.3",
        "drupal/smart_trim": "^1.2",
        "drupal/smtp": "^1.0@beta",
        "drupal/swiftmailer": "^2.0",
        "drupal/telephone_formatter": "^1.0",
        "drupal/telephone_validation": "^2.2",
        "drupal/token": "^1.9",
        "drupal/token_filter": "^1.1",
        "drupal/toolbar_menu": "^2.1",
        "drupal/tour_ui": "^1.0@beta",
        "drupal/twig_tweak": "^2.1",
        "drupal/ultimate_cron": "^2.0@alpha",
        "drupal/update_helper": "^2",
        "drupal/upgrade_status": "^3.13",
        "drupal/username_enumeration_prevention": "^1.0",
        "drupal/userprotect": "^1.1",
        "drupal/views_bootstrap": "^4.2",
        "drupal/views_bulk_edit": "^2.4",
        "drupal/views_bulk_operations": "^3.6",
        "drupal/views_data_export": "^1.0",
        "drupal/viewsreference": "^1.4",
        "drupal/vmi": "^2.5",
        "drupal/webform": "^6.1",
        "drupal/webform_views": "^5.0@alpha",
        "drupal/weight": "^3.1",
        "drupal/yoast_seo": "^1.5",
        "drush-ops/behat-drush-endpoint": "^0.0.5",
        "drush/drush": "~10",
        "emulsify-ds/emulsify-drupal": "2.x",
        "geocoder-php/google-maps-provider": "^4.5",
        "google/charts": "45",
        "guzzlehttp/guzzle": "^6.3",
        "pantheon-systems/quicksilver-pushback": "~1",
        "rvtraveller/qs-composer-installer": "^1.1",
        "wikimedia/composer-merge-plugin": "^1.4"
    },
    "conflict": {
            "drupal/drupal": "*"
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "autoload": {
        "classmap": [
            "scripts/composer/ScriptHandler.php"
        ]
    },
    "scripts": {
        "build-assets": [
            "@prepare-for-pantheon",
            "composer install --optimize-autoloader --no-dev"
        ],
        "drupal-scaffold": "DrupalComposer\\DrupalScaffold\\Plugin::scaffold",
        "prepare-for-pantheon": "DrupalProject\\composer\\ScriptHandler::prepareForPantheon",
        "remove-git-submodules": "find . -mindepth 2 -type d -name .git | xargs rm -rf",
        "post-install-cmd": [
            "@drupal-scaffold",
            "DrupalProject\\composer\\ScriptHandler::createRequiredFiles",
            "@remove-git-submodules"
        ],
        "post-update-cmd": [
            "DrupalProject\\composer\\ScriptHandler::createRequiredFiles",
            "@remove-git-submodules"
        ],
        "post-create-project-cmd": [
            "@drupal-scaffold",
            "DrupalProject\\composer\\ScriptHandler::createRequiredFiles"
        ]
    },
    "extra": {
        "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/contrib/{$name}": ["type:drupal-drush"]
        },
        "build-env": {
            "install-cms": [
                "drush site-install standard --account-mail={account-mail} --account-name={account-name} --account-pass={account-pass} --site-mail={site-mail} --site-name={site-name} --yes",
                "drush pm-enable config_direct_save simple_block --yes",
                "drush pm-uninstall block_content --yes"
            ],
            "export-configuration": "drush config-export --yes"
        },
        "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"
            ]
        },
        "patches": {
            "drupal/domain_entity": {
                "Issue #3005995: Default domain values not being assigned": "https://www.drupal.org/files/issues/2018-10-18/3005995-fix-defaults-add-presave.patch"
            },
            "drupal/core": {
                "Issue #2985882: Error: Call to a member function getLabel() after enable layout_builder": "https://www.drupal.org/files/issues/2018-07-16/2985882-entityfield-2.patch"
            },
            "drupal/entity_embed": {
                "Issue #3070343: Allow to add a Drupal core link with Link Widget for Image entities using Entity Embed Dialog in CKEditor": "https://www.drupal.org/files/issues/2019-07-25/3070343-8.patch"
            },
            "drupal/nodeaccess": {
                "Issue #2985045: The settings do not respond to creating and deleting roles": "https://www.drupal.org/files/issues/2019-02-18/nodeaccess_roles_sync-2985045-14.patch"
            },
            "drupal/recaptcha": {
                "Issue #2493183: Ajax support / Use behaviors for 2.x": "https://www.drupal.org/files/issues/2020-07-29/recaptcha-ajax-2493183-212.patch"
            },
            "drupal/better_exposed_filters": {
                "Issue #3224329: Autosubmit not working with jQuery Datepicker": "https://www.drupal.org/files/issues/2021-07-19/3224329-datepicker-autocomplete-5.patch"
            }
        }
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true,
        "platform": {
            "php": "7.4.0"
        }
    }
}
leymannx avatar
ne flag
What version of Composer/PHP/OS? You could remove them manually from composer.json and then run `composer update --lock`. Next `composer install` they should be removed.
Delford Chaffin avatar
gg flag
@leymannx - Ubuntu 20.04.2 on Windows 10 WSL, PHP 7.4.23. I'd run with --lock before, but not install. Just tried it though and nothing changed.
leymannx avatar
ne flag
So you removed the lines requiring these dependencies from the composer.json manually? Or have they never been there? And in the lock file how are they listed? As dependency of some other package?
leymannx avatar
ne flag
Can you add your comoser.json to the question, please? I'm guessing that there are other packages requiring this varbase core package. Also the core in the name may suggest that.
Delford Chaffin avatar
gg flag
@leymannx - I have tried removing them manually from composer.json and removing them with the remove command. Just now I tried removing them from the .lock file manually and that didn't help. I also deleted /vendor and /composer.lock and ran composer install and they came back. I put my composer.json file above, but the three modules are not currently there. There is varbase_media which depends on varbase_code which depends on media_entity. I'm trying to remove all three.
cn flag
`composer why drupal/varbase_core` may shed some light. Leymannx is probably right, something else probably depends on that module so even if you remove it from root requirements, it'll come back when dependencies are recalculated on update
Delford Chaffin avatar
gg flag
Cool. Didn't know about that `why` command. `drupal/varbase_media 5.0.0-alpha5 requires drupal/varbase_core (*)` ... `drupal/entity_browser_generic_embed 5.0.0-alpha5 requires drupal/varbase_media (self.version)` ... `drupal/varbase_core 4.1.0 requires drupal/media_entity (*)' Looks like the only dependencies are just among those 3 modules, all of which I'm trying to remove.
cn flag
Your composer.json has `drupal/entity_browser_generic_embed` in it so that does make sense. Maybe you forgot to remove that one? To make sure you can nuke them in one go `composer remove drupal/varbase_core drupal/varbase_media drupal/entity_browser_generic_embed`
Delford Chaffin avatar
gg flag
@Clive - I think that was the answer. That module was part of varbase_media and I guess I missed that it was separately in composer.json as well. Thanks!
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.