Skip to content

When setting config and unsettling config again, an empty config section still remains in composer.json #7691

@7ochem

Description

@7ochem

My composer.json, I created with composer init:

{
    "name": "7ochem/composer-test",
    "description": "Showing config unset leaves empty config",
    "type": "project",
    "license": "proprietary",
    "minimum-stability": "stable",
    "require": {}
}

Output of composer diagnose:

Checking composer.json: OK
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com oauth access: OK
Checking disk free space: OK
Checking pubkeys: 
Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0  87719BA6 8F3BB723 4E5D42D0 84A14642
Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B  0C708369 153E328C AD90147D AFE50952
OK
Checking composer version: OK
Composer version: 1.7.2
PHP version: 7.0.32
PHP binary path: /usr/bin/php7.0

When I run this command:

composer config platform.php 5.6

I get the following output in a Git diff:

diff --git a/composer.json b/composer.json
index bf864ab..494f626 100644
--- a/composer.json
+++ b/composer.json
@@ -4,5 +4,10 @@
     "type": "project",
     "license": "proprietary",
     "minimum-stability": "stable",
-    "require": {}
+    "require": {},
+    "config": {
+        "platform": {
+            "php": "5.6"
+        }
+    }
 }

When I run this command:

composer config --unset platform.php

I get the following output in a Git diff:

diff --git a/composer.json b/composer.json
index bf864ab..5d9990c 100644
--- a/composer.json
+++ b/composer.json
@@ -4,5 +4,10 @@
     "type": "project",
     "license": "proprietary",
     "minimum-stability": "stable",
-    "require": {}
+    "require": {},
+    "config": {
+        "platform": {
+
+        }
+    }
 }

And I expected that if the config (and underlying platform) section is empty, it will be removed again and restoring the composer.json to its original state and thus git diff not showing any changes.

Upon running composer init Composer doesn't generate a config section. So I also expect composer to restore it to that state when I use Composer to remove all configuration through it's built in commands and thus leaving no changes in the state of my VCS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions