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

[2.3] php8.1 selfupdate error when no old files exist #10696

Closed
it-can opened this issue Apr 2, 2022 · 0 comments
Closed

[2.3] php8.1 selfupdate error when no old files exist #10696

it-can opened this issue Apr 2, 2022 · 0 comments
Labels
Milestone

Comments

@it-can
Copy link

@it-can it-can commented Apr 2, 2022

I get this error after a fresh install on my mac machine with php8.1, I run this command

composer self-update --clean-backups

You are already using the latest available Composer version 2.3.3 (stable channel).

In SelfUpdateCommand.php line 491:

  [TypeError]
  Composer\Command\SelfUpdateCommand::cleanBackups(): Argument #2 ($except) must be of type
   ?string, bool given, called in phar:///usr/local/bin/composer/src/Composer/Command/SelfU
  pdateCommand.php on line 215


Exception trace:
  at phar:///usr/local/bin/composer/src/Composer/Command/SelfUpdateCommand.php:491
 Composer\Command\SelfUpdateCommand->cleanBackups() at phar:///usr/local/bin/composer/src/Composer/Command/SelfUpdateCommand.php:215
 Composer\Command\SelfUpdateCommand->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

The problem is caused by this function

protected function cleanBackups(string $rollbackDir, ?string $except = null): void

cleanBackups(string $rollbackDir, ?string $except = null): void

$except is excpected to be a string, but a boolean will be passed if there are no backup files available... See function getLastBackupVersion

protected function getLastBackupVersion(string $rollbackDir)

This function will return false when there are no old backups...

I created a PR #10704

it-can added a commit to it-can/composer that referenced this issue Apr 4, 2022
@it-can it-can changed the title php8.1 selfupdate error when no old files exist [2.3] php8.1 selfupdate error when no old files exist Apr 4, 2022
@Seldaek Seldaek added this to the 2.3 milestone Apr 6, 2022
@Seldaek Seldaek added the Bug label Apr 6, 2022
@Seldaek Seldaek closed this as completed in 106149d Apr 6, 2022
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

2 participants