What to do when composer fails to update your vendor packages?

You are viewing revision #10 of this wiki article.
This version may not be up to date with the latest version.
You may want to view the differences to the latest version or see the changes made in this revision.

« previous (#9)next (#18) »

  1. Problem Statement
  2. Solution

Problem Statement

Do you face some of these problems when using composer with your Yii install?

  • Running a composer update does not fetch any new packages (even though the source is updated)
  • A specific vendor package never gets updated
  • Facing on and off problems when fetching packages while performing composer update.
  • You ran a composer update earlier, but it was partially done, before you lost network connectivity, and you cannot refresh packages anymore.

Solution

Normally you need to check the package sources and if your network connectivity is stable when doing a composer update. But in most such cases above (even though rare), you may need to refresh and reinstall your composer packages.

The normal approach is to reinstall packages. Do the following:

  1. Backup your vendor folder under your app root, and delete all files in the vendor folder, except .gitignore if it exists.
  2. Backup your composer.lock file on your app root, and delete it.
  3. Run the following command from your application root:
php composer.phar install --prefer-dist

All the packages will be refreshed by composer using the cached versions if they are the latest.

Now check and see if your problem is resolved by checking your package versions. You should also test a php composer.phar update after this when a new package update is available, and see if it works.

You may reconfigure your composer.lock if needed.

Note: If you feel something is gone wrong, you can revert and restore your files from your backups taken in steps 1 and 2