问题描述
我已经有一段时间写过laravel代码了.目前,我尝试从github克隆项目并在本地进行编辑.我在项目目录中安装了composer,但未包含供应商文件夹,我尝试运行 composer install
,但出现此错误
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
我该如何解决?
注意:我已经尝试在以前的克隆上运行 composer update
,但这是行不通的.
Note: I have tried running composer update
on previous clones and that didn't work.
推荐答案
在大多数情况下,这是由于PHP 8导致的(我的情况是,即使我的项目是php 7.4,GitHub CI操作也会自动开始使用PHP 8)
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)
如果您安装了多个PHP(例如同一台服务器中的7.4和8),则可以通过这种方法进行修复.
If you have multiple PHP installations (E.g. 7.4 and 8 in the same server), this is how you can fix it.
指定您的php版本是您的composer.json文件
Specify your php version is your composer.json file
"config": {
"platform": {
"php": "7.3"
}
},
如果已经提交了锁定文件,则在将以上行添加到composer.json中之后运行composer update,然后提交新的锁定文件.(请注意,作曲家更新会将您的软件包升级到最新版本)
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)
这篇关于Laravel composer安装出现错误“您的锁定文件不包含兼容的软件包集,请运行composer update".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!