php - Laravel composer install giving error "Your lock file does not contain a compatible set of packages please run composer update"
Get the solution ↓↓↓I have been writing laravel code for quite sometime. Currently, I tried cloning a project from github and editing locally. I installed composer in my project directory but a vendor folder was not included, I tried to runcomposer install
but I gives me this error
Your lock file does not contain a compatible set of packages. Please run composer update
How do I resolve this?
Note: I have tried runningcomposer update
on previous clones and that didn't work.
Answer
Solution:
Run this command:
composer install --ignore-platform-reqs
or
composer update --ignore-platform-reqs
Answer
Solution:
Disclaimer, this solution will not fix the issue for PHP 8 projects.
In most cases this happens because of PHP 8 (In my case it was GitHub CI actions automatically started using PHP 8 even though my project is php 7.4)
If you have multiple PHP installations (E.g. 7.4 and 8 in the same server), this is how you can fix it.
Specify your php version is your composer.json file
"config": {
"platform": {
"php": "7.3"
}
},
If you have the lock file already committed, run composer update after you adding above line in to the composer.json and then commit the new lock file. (Please be aware composer update will upgrade your packages to latest versions)
Answer
Solution:
I solved this problem with this command:
composer self-update --1
It probably works because at time that the project was developed, composer was on another version and when change the Major version from 1 to 2 the compatibility was broke. With this command you downgrade composer and probably going to solve this
Answer
Solution:
You should try runningcomposer update --lock
that will update all packages and recreate the compose.lock file.
Either you can delete the composer.lock file and runcomposer install
that will also recreate the .lock file.
This resolved my issue.
Answer
Solution:
I faced this problem with my cakephp project in garuda linux (arch based)
Fix :
- Install php-intl using
sudo pacman -S php-intl
- Enable php intl by editing php config ( in my case
/etc/php/php.ini
) . addextension=intl
or uncomment the existing one - restart apache or whatever you are using
Answer
Solution:
I had the same error deploying another project with composer, but the problem was a missing php extension.
I understand you solve your problem but for anyone seeing the same error message, here is a general guidance :
The error messageYour lock file does not contain a compatible set of packages. Please run composer update
is shown each time there is a conflict during the dependency solving step of composer install. (see the relevant part in composer source code)
It doesn't inform on the real problem though, and it could be hard to guess.
To get the exact explanation you can add--verbose
option tocomposer install
command (the option is available to any composer command (see the doc)) :composer install --verbose
It will give you the full message explaining what exactly is preventing composer install from completing (package version conflict, missing php extension, etc.), then you'll be able to fix the problem.
Hope this could help.
Answer
Solution:
I had this error with Github Actions trying to deploy a Laravel app, this is probably different than the OP's case but none of the suggestions worked for me. Adding my answer here just in case there is someone else out there with a similar problem to mine.
I had to disable-q
in Github Actions and see that it was complaining about extensions not being installed.
Make sure yourrequire
section of composer's php extensions matches theextensions:
in your github action file forshivammathur/setup-php@v2
and it will deploy again
Answer
Solution:
In my case this problem is occuring in Ubuntu 20.04 Desktop. This is due to some missing packages.
I ran the following commands to install some packages then rerun Composer install and its working properly. The commands are:
sudo apt-get install php-mbstring
sudo apt-get install php-xml
Then rerun composer install
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: cannot add or update a child row: a foreign key constraint fails
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.