command-linecomposer-php

Remove repositories from composer command line


My project had a dependency that was on github, so when I installed it I ran

$ composer config repositories.vendor/package vcs https://github.com/vendor/package.git
$ composer require vendor/package

Now, I need to remove that package.
If I just run $ composer remove vendor/package the "repositories" section is still in my composer.json file.

"repositories": {

        "type": "vcs",
        "url": "https://github.com/vendor/package.git"
    },

How can I also remove the "repositories" section from the command line?


Solution

  • You can run composer config --unset repositories.vendor/package to remove the entry from the repositories key.

    However, this will still keep the empty repositories key. If you also want to remove that, you will have to use another tool that is able to parse JSON and remove the key yourself.