Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composer 1.4.0 composer.json does not match the expected JSON schema: #6238

Closed
tolson17 opened this issue Mar 8, 2017 · 12 comments
Closed
Labels

Comments

@tolson17
Copy link

tolson17 commented Mar 8, 2017

This issue started when I upgraded to version 1.4.0

My composer.json:

{
    "name": "dash/dash-platform",
    "description": "The full meal deal",
    "config" : {
      "secure-http": false
    },
    "license": "proprietary",
    "type": "project",
    "minimum-stability": "stable",
    "repositories": [
        {
            "type": "pear",
            "url": "pear.php.net"
        }
    ],
    "require": {
        "php": ">=5.6.0",
        "ext-curl": "*",
        "ext-json": "*",
        "ext-imagick": "*",
        "ext-xml": "*",
        "ext-xsl": "*",
        "ext-dom": "*",
        "ext-pcntl": "*",

        "google/recaptcha": "~1.1",
        "nesbot/carbon": "~1.14",
        "aws/aws-sdk-php": "2.*",
        "symfony/http-foundation": "2.*",
        "symfony/dependency-injection": "2.*",
        "symfony/http-kernel": "2.*",
        "symfony/yaml": "2.*",
        "symfony/event-dispatcher": "2.*",
        "doctrine/cache": "*",
        "monolog/monolog": "^1.13@dev",
        "smarty/smarty": "3.1.29",
        "tecnickcom/tcpdf": "6.0.*",
        "facebook/php-sdk-v4" : "4.0.*",
        "phpunit/phpunit": "~4.7",
        "phpunit/php-invoker": "*",
        "phpunit/dbunit": ">=1.2",
        "phpunit/phpunit-selenium": ">=1.2",
        "phpunit/phpunit-story": "1.0.*",
        "pear-pear.php.net/pear": "*",
        "pear-pear.php.net/image_barcode2": "*",
        "pear-pear.php.net/validate": "*",
        "pear-pear.php.net/validate_us": "*",
        "pear-pear.php.net/validate_ca": "*",
        "pear-pear.php.net/pager": "*",
        "pear-pear.php.net/spreadsheet_excel_writer": "*",
        "pear-pear.php.net/xml_query2xml": "*",
        "pear-pear.php.net/mail": "*",
        "pear-pear.php.net/mail_mime": "*",
        "pear-pear.php.net/services_shorturl": "*",
        "pear-pear.php.net/structures_datagrid": "*",
        "pear-pear.php.net/structures_datagrid_datasource_mdb2": "*",
        "pear-pear.php.net/structures_datagrid_datasource_array": "*",
        "pear-pear.php.net/structures_datagrid_renderer_xls": "*",
        "pear-pear.php.net/structures_datagrid_renderer_htmltable": "*",
        "pear-pear.php.net/structures_datagrid_renderer_pager": "*",
        "pear-pear.php.net/structures_datagrid_renderer_csv": "*",
        "pear-pear.php.net/mdb2": "*",
        "pear-pear.php.net/mdb2_driver_mysql": "*",
        "pear-pear.php.net/mdb2_driver_mysqli": "*",
        "pear-pear.php.net/html_common": "*",
        "pear-pear.php.net/html_table": "*",
        "php-console/php-console": "3.*",
        "psr/http-message": "1.0",
        "jaspersoft/rest-client": "dev-master#32dc45485030c6339e636c309cd5280af6479bf4",
        "phpmailer/phpmailer": "~5.2",
        "symfony/options-resolver": "2.*",
        "symfony/console": "3.2.3",
        "symfony/finder": "^3.0",
        "jdorn/sql-formatter": "*",
        "phpunit/phpunit-mock-objects": "~2.3",
        "symfony/process": "^3.1",
        "twig/twig": "1.25.*",
        "guzzlehttp/guzzle": "~6.0"
    },
    "scripts": {
        "post-install-cmd": [
            "php security-checker.phar security:check ./composer.lock"
        ],
        "post-update-cmd": [
            "php security-checker.phar security:check ./composer.lock"
        ]
    },
    "require-dev": {
        "filp/whoops": "^2.1",
        "symfony/var-dumper": "^3.0"
    }
}

When I run this command:

// anything with composer.phar, even trying to roll back
./composer.phar install; 

I get the following output...same when running diagnose:

  [Composer\Json\JsonValidationException]                                                                                                                           
  "./composer.json" does not match the expected JSON schema:                                                                                                        
   - repositories[0] : Must contain no more than 1 properties                                                                                                       
   - repositories[0].url : String value found, but a boolean is required                                                                                            
   - repositories[0].url : Does not have a value in the enumeration [false]                                                                                         
   - repositories[0].package : The property package is required                                                                                                     
   - repositories[0].type : Does not have a value in the enumeration ["package"]                                                                                    
   - repositories[0].type : Does not have a value in the enumeration ["composer"]                                                                                   
   - repositories[0].url : Invalid URL format                                                                                                                       
   - repositories[0].type : Does not have a value in the enumeration ["vcs","github","git","gitlab","git-bitbucket","hg","hg-bitbucket","fossil","perforce","svn"]  
   - repositories[0].type : Does not have a value in the enumeration ["path"]                                                                                       
   - repositories[0].type : Does not have a value in the enumeration ["artifact"]                                                                                   
   - repositories[0] : Failed to match exactly one schema  
@atippett
Copy link

atippett commented Mar 9, 2017

+1

1 similar comment
@jordikroon
Copy link

+1

@Seldaek
Copy link
Member

Seldaek commented Mar 9, 2017

The reason is you didn't specify a valid URL for the PEAR repo:

            "url": "pear.php.net"

Add https:// and all will be well: "url": "https://pear.php.net"

@Seldaek Seldaek closed this as completed Mar 9, 2017
@Seldaek Seldaek added the Support label Mar 9, 2017
@jordikroon
Copy link

jordikroon commented Mar 9, 2017

@Seldaek What about this configuration? It used to work in 1.3.0.

    "repositories": [
        {
            "type": "vcs",
            "url": "http://svn.esites/projects/matchday-commons/maxx-xs-sdk/",
            "trunk-path": "Trunk",
            "branches-path": false,
	    "tags-path": false,
            "svn-cache-credentials": false
        }
    ]

[Composer\Json\JsonValidationException]                                           
  "./composer.json" does not match the expected JSON schema:                        
   - repositories[0] : Must contain no more than 1 properties                       
   - repositories[0].url : String value found, but a boolean is required            
   - repositories[0].url : Does not have a value in the enumeration [false]         
   - repositories[0].trunk-path : String value found, but a boolean is required     
   - repositories[0].trunk-path : Does not have a value in the enumeration [false]  
   - repositories[0].package : The property package is required                     
   - repositories[0].type : Does not have a value in the enumeration ["package"]    
   - repositories[0].type : Does not have a value in the enumeration ["composer"]   
   - repositories[0].branches-path : Boolean value found, but a string is required  
   - repositories[0].tags-path : Boolean value found, but a string is required      
   - repositories[0].type : Does not have a value in the enumeration ["path"]       
   - repositories[0].type : Does not have a value in the enumeration ["artifact"]   
   - repositories[0].type : Does not have a value in the enumeration ["pear"]       
   - repositories[0] : Failed to match exactly one schema    

@Seldaek
Copy link
Member

Seldaek commented Mar 9, 2017

@jordi12100 ok that one was indeed a bug on our end. Should be fixed in latest snapshot, try with composer self-update --snapshot (you probably have to run this from outside the directory so it doesn't try to validate your composer.json)

@jordikroon
Copy link

Thanks for the fast support. It's all working now.

@tolson17
Copy link
Author

tolson17 commented Mar 9, 2017

@Seldaek thank you!

@jkribeiro
Copy link

jkribeiro commented Mar 9, 2017

I have the following config:

"repositories": [
        {"type": "composer", "url": "https://myprivatepackagist.com"},
        {"packagist": false}
    ]

My test build add other repo to the list, running something like:
composer config repositories.foo vcs https://github.com/foo/bar

After this command, my composer config is set to:

    "repositories": {
        "0": {
            "type": "composer",
            "url": "https://myprivatepackagist.com"
        },
        "1": {
            "packagist": false
        },
        "foo": {
            "type": "vcs",
            "url": "https://github.com/foo/bar"
        }
    }

Running any type of composer command like composer config --list I'm receiving the same error:

  [Composer\Json\JsonValidationException]                                
  "./composer.json" does not match the expected JSON schema:             
   - repositories[1] : Object value found, but a boolean is required     
   - repositories[1] : Does not have a value in the enumeration [false]  
   - repositories[1].type : The property type is required                
   - repositories[1].package : The property package is required          
   - repositories[1].url : The property url is required                  
   - repositories[1] : Failed to match exactly one schema     

@stof
Copy link
Contributor

stof commented Mar 10, 2017

hmm, the issue is the conversion between array-based and object-based repository (and this stricter validation allowed to discover a bug in composer config.
The proper way to disable package in an object-based config should be "packagist": false, not "1": { "packagist": false }

@Seldaek
Copy link
Member

Seldaek commented Mar 10, 2017

both work though AFAIK..

As a workaround you can probably do composer config repositories.2 vcs https://github.com/foo/bar which will set it as the second repo in the array, or define your repositories as an object in the base composer.json so adding one key doesn't mess it up..

We probably need to fix this in the config command though :)

@Seldaek
Copy link
Member

Seldaek commented Mar 10, 2017

@jkribeiro please report a new issue for this.

@jkribeiro
Copy link

jkribeiro commented Mar 10, 2017

Issue created #6245

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants