Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel composer install giving error "Your lock file does not contain a compatible set of packages please run composer update"

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 run composer 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 running composer update on previous clones and that didn't work.

like image 872
Zeekstem Avatar asked Dec 29 '20 17:12

Zeekstem


2 Answers

Run this command:

composer install --ignore-platform-reqs

or

composer update --ignore-platform-reqs
like image 180
Happy Patel Avatar answered Oct 19 '22 19:10

Happy Patel


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 on the same server), this is how you can fix it.

Specify your php version in 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)

like image 18
M_R_K Avatar answered Oct 19 '22 20:10

M_R_K