我尝试使用 Composer 将 google api 下载到旧代码,但是出现以下错误:
composer require google/apiclient:^2.0
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for google/apiclient 2.0 -> satisfiable by google/apiclient[v2.0.0].
- google/apiclient v2.0.0 requires google/auth 0.8 -> satisfiable by google/auth[v0.8].
- Conclusion: don't install guzzlehttp/psr7 1.4.2
- google/auth v0.8 requires guzzlehttp/psr7 1.2.* -> satisfiable by guzzlehttp/psr7[1.2.0, 1.2.1, 1.2.2, 1.2.3].
- Can only install one of: guzzlehttp/psr7[1.2.0, 1.4.2].
- Can only install one of: guzzlehttp/psr7[1.2.1, 1.4.2].
- Can only install one of: guzzlehttp/psr7[1.2.2, 1.4.2].
- Can only install one of: guzzlehttp/psr7[1.2.3, 1.4.2].
- Installation request for guzzlehttp/psr7 (locked at 1.4.2) -> satisfiable by guzzlehttp/psr7[1.4.2].
Installation failed, reverting ./composer.json to its original content.
我该怎么办?
尝试删除供应商/谷歌,然后再次运行
composer install
,这对我有用。
只能安装其中之一:
[guzzlehttp/psr7
,1.2.3
]。1.4.2
您的依赖项导致软件包的两个不同主要版本混淆,但只能安装一个。
locked at 1.4.2
消息意味着该软件包已根据您的composer.lock
文件安装,并且您正在尝试安装与您现有条件不兼容的不同版本。
$ composer show -a google/auth | grep psr7
guzzlehttp/psr7 ~1.2
您可以通过检查依赖树来检查哪个现有包依赖于锁定版本:
composer show -t
在某些情况下,删除
composer.lock
可能会有所帮助。
否则,要查看为什么(从哪里)引用该包,请运行:
composer why guzzlehttp/psr7 -t
另请参阅:如何解决“只能安装其中之一:”冲突?
我终于找到了适合我的解决方案,只需删除
composer.lock
!!
就我而言,这是有效的:
之后您可以将超时减少回 600。