Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
203 views
in Technique[技术] by (71.8m points)

php - How to explain Composer's error log?

I did a lot of research on the web, but did not find a documentation of the composer error log. In the discussions I found, nobody had an explanation that was consistent with the error log. For example:

I know, what composer does and can resolve issues on my own, but I often have to consult packagist.org for this. Despite being quite (and unnecessarily) verbose, the composer log only gives me some hints. It does not really point out the concrete problems.

Does anyone know of a complete documentation or how to explain the reasoning behind the logs, maybe taking the above ones as an example?

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Documentation of Composer can be found at getcomposer.org/doc, especially Troubleshooting section. Usually the dependency problems comes from misconfiguration of your composer.json and understanding Composer logs comes with experience or learning on trial and error. Documenting every possible errors out of hundreds can become quickly outdated. If you believe some specific error isn't clear enough, you can always raise a new suggestion at the Composer's GitHub page.

As suggested in linked GitHub issue, "Conclusion: don't install" message it could be related to requirements defined in minimum-stability. Another linked question could be related to Composer's bug as reported at GH-7215.

Errors

Here is a small guide explaining the common Composer's errors:

  • Can only install one of: org/package[x.y.z, X.Y.Z].

    If you see this messages, that could be the main cause of the dependency issue. It basically means that based on the Composer's dependency calculation both of these versions are required, but only one major version can be installed (you cannot have both x.y.z and X.Y.Z, unless you split your configuration for different folders). To see why these packages are required, use the composer why/depends command and adjust the dependencies accordingly.

    See: How to resolve a "Can only install one of:" conflict? & How to solve two packages requirements conflicts when running composer install?

  • Installation request for org/package2 (locked at vX.Y.Z)

    This message means that there was an installation request for org/package, however, it is locked at X.Y.Z. If the requested version is not compatible with the locked version (like a different major version), you cannot install both. This message often comes along with already mentioned "Can only install one" one. So, whenever you see "locked at", that means Composer reads your installed package version from the composer.lock file. To troubleshoot, you can use composer why/depends command to find why the package was requested and adjust the compatibility, otherwise, you may try to remove composer.lock file and start from scratch (ideally from the empty folder).

    See: Installation failed for laravel/lumen-installer: guzzlehttp/guzzle locked at 6.3.0

  • org/package1 vx.y.z conflicts with org/package2[vX.Y.Z].

    It is a similar issue as above where two packages are conflicting and you need to solve the dependency manually. Reading the whole context of the message may give you some more clues. Checking the dependency tree may also help (composer show -t).

  • conflict with your requirements or minimum-stability

    This message means as it reads, so you should check the required version and/or your minimum-stability settings.

This can be caused by a package being marked as non-stable and your requirements being "stable only. See: But these conflict with your requirements or minimum-stability

Or because of conflicts with other installed packages. See: How to identify what is preventing Composer from installing latest version of a package?.

For any other errors, check out the official Composer's Troubleshooting page.

Troubleshooting

Here are more suggestions how to troubleshoot the Composer dependency issues in general:

  • Add -v/-vv/-vvv parameter to your command for more verbose output.
  • Run composer diagnose to check for common errors to help debugging problems.
  • If you seeing "locked at x.y.z" messages, it relates to packages locked in your composer.lock.
  • Test your composer.json on the empty folder.
  • Keep your composer.json to minimum.
  • Run composer show -t to see your current dependency tree.
  • Run composer show -a org/package x.y.z to check the details about the package.
  • Feel free to ask a new question at Stack Overflow.

To fully debug Composer's dependency problem, you can:


Useful threads explaining common errors:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...