Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force composer to reinstall a library?

People also ask

How do I update my composer library?

To update your packagesRun composer update (on your local machine) to update the required packages and re-generate a composer. lock file. Commit the updated composer. lock file to your git repository.

How do I update dependency in composer?

Updating dependencies to their latest versions# To update to the latest versions, use the update command. This will fetch the latest matching versions (according to your composer. json file) and update the lock file with the new versions.


First execute composer clearcache

Then clear your vendors folder

rm -rf vendor/*

or better yet just remove the specific module which makes problems to avoid having to download all over again.


You can use the --prefer-source flag for composer to checkout external packages with the VCS information (if any available). You can simply revert to the original state. Also if you issue the composer update command composer will detect any changes you made locally and ask if you want to discard them.

Your .gitignore file is related to your root project (ZF2 skeleton) and it prevents the vendor dir (where your third party libs are) from committing to your own VCS. The ignore file is unrelated to the git repo's of your vendors.


I didn't want to delete all the packages in vendor/ directory, so here is how I did it:

  1. rm -rf vendor/package-i-messed-up
  2. composer install again

What I did:

  1. Deleted that particular library's folder
  2. composer update --prefer-source vendor/library-name

It fetches the library again along with it's git repo


Reinstall the dependencies. Remove the vendor folder (manually) or via rm command (if you are in the project folder, sure) on Linux before:

rm -rf vendor/

composer update -v

https://www.dev-metal.com/composer-problems-try-full-reset/


Short answer

you can execute it in one cli command with &&:

composer remove vendor/package && composer require vendor/package:version

Detailed answer

Remove existing package by command:

composer remove vendor/package

this will remove folder of package from /vendor, row from composer.json and whole record of package from composer.lock right way with removing not used dependencies and not removing dependencies which used by another packages

Then install preferred one with command:

composer require vendor/package:version

this will install package with desired version right way with adding row to composer.json, adding record to composer.lock and all needed dependent packages if there would be package which is used in more that one package, Composer will try to install version which fits all using packages. If it will not resolve this it will crash with corresponding error message

Links

How to install a specific version of package using Composer?

How to remove a package from Laravel using composer?

Install, Uninstall and Update Modules Themes etc with Composer: https://modulesunraveled.com/drupal-8-composer-and-configuration-management/installing-and-uninstalling-modules-composer


As user @aaracrr pointed out in a comment on another answer probably the best answer is to re-require the package with the same version constraint.

ie.

composer require vendor/package

or specifying a version constraint

composer require vendor/package:^1.0.0