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

ZipArchiver::supports(): Argument #2 ($sourceType) must be of type string, null given #10702

mikkoaf opened this issue Apr 4, 2022 · 5 comments


Copy link

@mikkoaf mikkoaf commented Apr 4, 2022

Output of composer diagnose:

$ composer diagnose
Checking composer.json: WARNING
The version field is present, it is recommended to leave it out if the package is published on Packagist.
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking 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
Checking composer version: OK
Composer version: 2.3.3
PHP version: 8.0.17
PHP binary path: /usr/bin/php8.0
OpenSSL version: OpenSSL 1.1.1f  31 Mar 2020
cURL version: 7.68.0 libz 1.2.11 ssl OpenSSL/1.1.1f
zip: extension present, unzip present, 7-Zip not available

When I run this command:

composer archive --format=zip --file=composer-archive

I get the following output:

$ composer archive --format=zip --file=composer-archive
Creating the archive into ".".

In ZipArchiver.php line 81:

  Composer\Package\Archiver\ZipArchiver::supports(): Argument #2 ($sourceType) must be of type string, null given, called in phar:///usr/local/bin/composer/src/Composer/Package/Archiver/ArchiveManager.php o
  n line 133

Exception trace:
  at phar:///usr/local/bin/composer/src/Composer/Package/Archiver/ZipArchiver.php:81
 Composer\Package\Archiver\ZipArchiver->supports() at phar:///usr/local/bin/composer/src/Composer/Package/Archiver/ArchiveManager.php:133
 Composer\Package\Archiver\ArchiveManager->archive() at phar:///usr/local/bin/composer/src/Composer/Command/ArchiveCommand.php:138
 Composer\Command\ArchiveCommand->archive() at phar:///usr/local/bin/composer/src/Composer/Command/ArchiveCommand.php:94
 Composer\Command\ArchiveCommand->execute() at phar:///usr/local/bin/composer/vendor/symfony/console/Command/Command.php:298
 Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:1015
 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:299
 Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:334
 Composer\Console\Application->doRun() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:130
 Composer\Console\Application->run() at phar:///usr/local/bin/composer/bin/composer:83
 require() at /usr/local/bin/composer:29

archive [-f|--format FORMAT] [--dir DIR] [--file FILE] [--ignore-filters] [--] [<package> [<version>]]
Copy link

@lubo13 lubo13 commented Apr 4, 2022

Hi, we've faced the same issue and we saw that in PharArchiver::supports the second passed argument from ArchiveManager::archive (line 100) is null.

We are also wondering why sourceType is passed if is not used?

Copy link

@tubbynl tubbynl commented Apr 6, 2022

this occurred in my CI-build where i used composer:2 as build image.

  • error occurred on version 2.3.3 and 2.3.2
  • error doesnt occur on version 2.2.11

i'm unsure what composer image version was used in on the original :2 version spec but perhaps this helps

my stacktrace

$ composer archive
Installing dependencies from lock file
Verifying lock file contents can be installed on current platform.
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. It is recommended that you run `composer update` or `composer update <package name>`.
Package operations: 0 installs, 0 updates, 33 removals
  - Removing webmozart/assert (1.10.0)
  - Removing doctrine/instantiator (1.4.1)
Generating optimized autoload files
30 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
Creating the archive into ".".
In ZipArchiver.php line 81:
  Composer\Package\Archiver\ZipArchiver::supports(): Argument #2 ($sourceType  
  ) must be of type string, null given, called in phar:///usr/bin/composer/sr  
  c/Composer/Package/Archiver/ArchiveManager.php on line 133                   
Exception trace:
  at phar:///usr/bin/composer/src/Composer/Package/Archiver/ZipArchiver.php:81
 Composer\Package\Archiver\ZipArchiver->supports() at phar:///usr/bin/composer/src/Composer/Package/Archiver/ArchiveManager.php:133
 Composer\Package\Archiver\ArchiveManager->archive() at phar:///usr/bin/composer/src/Composer/Command/ArchiveCommand.php:138
 Composer\Command\ArchiveCommand->archive() at phar:///usr/bin/composer/src/Composer/Command/ArchiveCommand.php:94
 Composer\Command\ArchiveCommand->execute() at phar:///usr/bin/composer/vendor/symfony/console/Command/Command.php:298
 Symfony\Component\Console\Command\Command->run() at phar:///usr/bin/composer/vendor/symfony/console/Application.php:1015
 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/bin/composer/vendor/symfony/console/Application.php:299
 Symfony\Component\Console\Application->doRun() at phar:///usr/bin/composer/src/Composer/Console/Application.php:334
 Composer\Console\Application->doRun() at phar:///usr/bin/composer/vendor/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at phar:///usr/bin/composer/src/Composer/Console/Application.php:130
 Composer\Console\Application->run() at phar:///usr/bin/composer/bin/composer:83
 require() at /usr/bin/composer:29
archive [-f|--format FORMAT] [--dir DIR] [--file FILE] [--ignore-filters] [--] [<package> [<version>]]

weird quirk in my case; it specifically failed on the tag-build, in both cases composer archive is ran identically but in the tag build the version is different (set using composer config version $CI_COMMIT_TAG)

Copy link

@tubbynl tubbynl commented Apr 6, 2022

ok; locally also reproducable when no version spec in the composer.json composer archive works; if i spec a version then it fails with the same stacktrace (using composer 2.3.3). Let me fix a example composer json file

Copy link

@tubbynl tubbynl commented Apr 6, 2022


    "name": "test",
    "support": {
        "email": ""
    "require": {
        "php": ">=8.1"
    "require-dev": {
        "phpunit/phpunit": "^9"
    "config": {
        "archive-format": "zip"
    "archive": {
        "name": "test"
composer archive
# fails
git init
git add .
git commit -m "init"
composer archive
# works
composer config version 1.0.0
composer archive
# fails

@Seldaek Seldaek added this to the 2.3 milestone Apr 6, 2022
@Seldaek Seldaek closed this as completed in eb36025 Apr 6, 2022
@Seldaek Seldaek added the Bug label Apr 6, 2022
Copy link

@tubbynl tubbynl commented Apr 8, 2022

i can verify it is fixed in 2.3.4 , tnx @Seldaek !

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

No branches or pull requests

4 participants