我尝试使用作曲家将谷歌 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
即可