Home > Mobile >  Unable to update composer
Unable to update composer

Time:11-03

I develop an app with Symfony5 and try to deploy on Heroku but got an error when deploying. Here is the build log :


 WARNING: Your 'composer.lock' is out of date!    
 The 'composer.lock' file in your project is not up to date with
 the main 'composer.json' file. This may result in installation
 of incorrect packages or package versions.    
 The lock file is required in order to guarantee reliable and
 reproducible installation of dependencies across systems and
deploys. It must always be kept in sync with 'composer.json'.

Whenever you change 'composer.json', ensure that you perform
the following steps locally on your computer:
1) run 'composer update'
2) add all changes using 'git add composer.json composer.lock'
3) commit using 'git commit'

Ensure that you updated the lock file correctly, and that you ran 'git add' on both files, before deploying again.
Please remember to always keep your 'composer.lock' updated in lockstep with 'composer.json' to avoid common problems related to dependencies during collaboration and deployment.

-----> Installing dependencies...
       Composer version 2.1.9 2021-10-05 09:47:38
       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>`.

WARNING: An error occurred during a database connection or query
ERROR: Dependency installation failed
 The 'composer install' process failed with an error. The cause may be the download or installation of packages, or a pre- or post-install hook (e.g. a 'post-install-cmd' item in 'scripts') in your 'composer.json'.    

Typical error cases are out-of-date or missing parts of code, timeouts when making external connections, or memory limits. Check the above error output closely to determine the cause of the problem, ensure the code you're pushing is functioning properly, and that all local changes are committed correctly.
    
REMINDER: the following warnings were emitted during the build;
check the details above, as they may be related to this error:
- Your 'composer.lock' is out of date!
- An error occurred during a database connection or query
Push rejected, failed to compile PHP app.
Push failed

So I try run composer update in the terminal but got this error message :

Loading composer repositories with package information
Restricting packages listed in "symfony/symfony" to "5.3.*"
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires phpunit/phpunit 4.7.7 -> satisfiable by phpunit/phpunit[4.7.7].
    - phpunit/phpunit 4.7.7 requires symfony/yaml ~2.1|~3.0 -> found symfony/yaml[v2.1.0, ..., v2.8.52, v3.0.0, ..., v3.4.47] but it conflicts with your root composer.json require (5.3.*).
  Problem 2
    - Root composer.json requires phpspec/phpspec 2.2.1 -> satisfiable by phpspec/phpspec[2.2.1].
    - phpspec/phpspec 2.2.1 requires symfony/console ~2.3 -> found symfony/console[v2.3.0, ..., v2.8.52] but it conflicts with your root composer.json require (5.3.*).

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

I understand there is conflict with phpunit, composer.json and .lock files but can't find how to solve this. Any help please?

CodePudding user response:

I resolved this. The problem was composer.lock wasn't concording with composer.json so I did these following steps :

  1. Remove composer.lock file :

    rm -rf composer.lock

  2. Update composer (it will automatically create composer.lock file) :

    composer update

  3. Verify composer.lock has the same dependencies version and update if necessary

  4. Save and push the modifications to git and heroku :

       git commit -m "Update composer files"
       git push
       git push heroku`
    

CodePudding user response:

PHPUnit 4.7.7 is horribly outdated (released in July 2015), and its dependencies clash with requiring Symfony 5.3. You should either install PHPUnit from a PHAR (which is the recommended way), or upgrade it to a more recent version

  • Related