2012-08-24 09:53:02 +00:00
<!--
tagline: Solving problems
-->
2012-08-27 15:46:40 +00:00
# Troubleshooting
This is a list of common pitfalls on using Composer, and how to avoid them.
2021-11-11 13:58:43 +00:00
2012-08-27 15:46:40 +00:00
## General
2021-08-31 18:44:46 +00:00
1. When facing any kind of problems using Composer, be sure to **work with the
2012-10-11 18:20:49 +00:00
latest version**. See [self-update ](../03-cli.md#self-update ) for details.
2021-10-25 11:11:56 +00:00
2021-08-31 18:44:46 +00:00
2. Before asking anyone, run [`composer diagnose` ](../03-cli.md#diagnose ) to check
for common problems. If it all checks out, proceed to the next steps.
2012-08-27 15:46:40 +00:00
2013-04-03 22:47:03 +00:00
3. Make sure you have no problems with your setup by running the installer's
2013-02-18 16:56:13 +00:00
checks via `curl -sS https://getcomposer.org/installer | php -- --check` .
2012-10-30 11:54:53 +00:00
2021-08-31 18:44:46 +00:00
4. Try clearing Composer's cache by running `composer clear-cache` .
5. Ensure you're **installing vendors straight from your `composer.json`** via
2012-10-08 17:42:28 +00:00
`rm -rf vendor && composer update -v` when troubleshooting, excluding any
possible interferences with existing vendor installations or `composer.lock`
entries.
2012-08-27 15:46:40 +00:00
2021-11-11 13:58:43 +00:00
2012-08-27 15:46:40 +00:00
## Package not found
1. Double-check you **don't have typos** in your `composer.json` or repository
branches and tag names.
2. Be sure to **set the right
2012-10-11 18:20:49 +00:00
[minimum-stability ](../04-schema.md#minimum-stability )**. To get started or be
2012-08-27 15:46:40 +00:00
sure this is no issue, set `minimum-stability` to "dev".
2012-11-08 14:08:02 +00:00
3. Packages **not coming from [Packagist](https://packagist.org/)** should
2012-08-27 15:46:40 +00:00
always be **defined in the root package** (the package depending on all
vendors).
4. Use the **same vendor and package name** throughout all branches and tags of
your repository, especially when maintaining a third party fork and using
`replace` .
2014-07-05 12:53:31 +00:00
5. If you are updating to a recently published version of a package, be aware that
2014-10-07 13:35:09 +00:00
Packagist has a delay of up to 1 minute before new packages are visible to Composer.
2014-07-05 12:53:31 +00:00
2015-09-05 09:46:02 +00:00
6. If you are updating a single package, it may depend on newer versions itself.
2015-09-07 16:55:30 +00:00
In this case add the `--with-dependencies` argument **or** add all dependencies which
2015-09-05 15:12:20 +00:00
need an update to the command.
2015-09-05 09:46:02 +00:00
2021-11-11 13:58:43 +00:00
## Package is not updating to the expected version
Try running `php composer.phar why-not [package-name] [expected-version]` .
2021-05-21 09:14:11 +00:00
## Dependencies on the root package
2013-02-19 15:18:45 +00:00
2021-05-21 09:14:11 +00:00
When your root package depends on a package which ends up depending (directly or
indirectly) back on the root package itself, issues can occur in two cases:
1. During development, if you are on a branch like `dev-main` and the branch has no
[branch-alias ](aliases.md#branch-alias ) defined, and the dependency on the root package
requires version `^2.0` for example, the `dev-main` version will not satisfy it.
The best solution here is to make sure you first define a branch alias.
2013-02-19 15:18:45 +00:00
2021-05-21 09:14:11 +00:00
2. In CI (Continuous Integration) runs, the problem might be that Composer is not able
to detect the version of the root package properly. If it is a git clone it is
generally alright and Composer will detect the version of the current branch,
but some CIs do shallow clones so that process can fail when testing pull requests
and feature branches. In these cases the branch alias may then not be recognized.
2013-02-19 15:18:45 +00:00
The best solution is to define the version you are on via an environment variable
2021-05-21 09:14:11 +00:00
called COMPOSER_ROOT_VERSION. You set it to `dev-main` for example to define
the root package's version as `dev-main` .
Use for example: `COMPOSER_ROOT_VERSION=dev-main composer install` to export
the variable only for the call to composer, or you can define it globally in the
CI env vars.
2013-01-06 20:00:36 +00:00
2021-11-11 13:58:43 +00:00
2022-10-27 14:58:13 +00:00
## Network timeout issues, curl error
If you see something along the lines of:
```
Failed to download * curl error 28 while downloading * Operation timed out after 300000 milliseconds
```
It means your network is probably so slow that a request took over 300seconds to complete. This is the
minimum timeout Composer will use, but you can increase it by increasing the `default_socket_timeout`
value in your php.ini to something higher.
2015-03-24 08:44:13 +00:00
## Package not found in a Jenkins-build
1. Check the ["Package not found" ](#package-not-found ) item above.
2021-05-21 09:14:11 +00:00
2. The git-clone / checkout within Jenkins leaves the branch in a "detached HEAD"-state. As
a result, Composer may not able to identify the version of the current checked out branch
and may not be able to resolve a [dependency on the root package ](#dependencies-on-the-root-package ).
To solve this problem, you can use the "Additional Behaviours" -> "Check out to specific local
branch" in your Git-settings for your Jenkins-job, where your "local branch" shall be the same
branch as you are checking out. Using this, the checkout will not be in detached state any more
and the dependency on the root package should become satisfied.
2015-03-24 08:44:13 +00:00
2021-11-11 13:58:43 +00:00
2016-01-11 09:23:14 +00:00
## I have a dependency which contains a "repositories" definition in its composer.json, but it seems to be ignored.
2017-12-15 18:33:31 +00:00
The [`repositories` ](../04-schema.md#repositories ) configuration property is defined as [root-only ](../04-schema.md#root-package ). It is not inherited. You can read more about the reasons behind this in the "[why can't
2022-02-19 11:52:00 +00:00
Composer load repositories recursively?](../faqs/why-cant-composer-load-repositories-recursively.md)" article.
2016-01-12 07:47:11 +00:00
The simplest work-around to this limitation, is moving or duplicating the `repositories` definition into your root
2016-01-11 09:23:14 +00:00
composer.json.
2021-11-11 13:58:43 +00:00
2016-01-11 09:23:14 +00:00
## I have locked a dependency to a specific commit but get unexpected results.
While Composer supports locking dependencies to a specific commit using the `#commit-ref` syntax, there are certain
2016-01-23 18:50:43 +00:00
caveats that one should take into account. The most important one is [documented ](../04-schema.md#package-links ), but
2016-01-11 09:23:14 +00:00
frequently overlooked:
> **Note:** While this is convenient at times, it should not be how you use
> packages in the long term because it comes with a technical limitation. The
> composer.json metadata will still be read from the branch name you specify
> before the hash. Because of that in some cases it will not be a practical
> workaround, and you should always try to switch to tagged releases as soon
> as you can.
2016-01-19 14:12:46 +00:00
There is no simple work-around to this limitation. It is therefore strongly recommended that you do not use it.
2016-01-11 09:23:14 +00:00
2021-11-11 13:58:43 +00:00
2013-04-27 15:51:05 +00:00
## Need to override a package version
2013-03-04 13:17:43 +00:00
2015-06-03 11:21:54 +00:00
Let's say your project depends on package A, which in turn depends on a specific
version of package B (say 0.1). But you need a different version of said package B (say 0.11).
2013-03-04 13:17:43 +00:00
2013-04-27 15:51:05 +00:00
You can fix this by aliasing version 0.11 to 0.1:
2013-03-04 13:17:43 +00:00
composer.json:
2013-04-27 15:51:05 +00:00
2014-05-19 10:17:07 +00:00
```json
{
"require": {
"A": "0.2",
"B": "0.11 as 0.1"
2013-03-04 13:17:43 +00:00
}
2014-05-19 10:17:07 +00:00
}
```
2013-03-04 13:17:43 +00:00
2013-04-27 15:51:05 +00:00
See [aliases ](aliases.md ) for more information.
2013-03-04 13:17:43 +00:00
2021-11-11 13:58:43 +00:00
## Figuring out where a config value came from
Use `php composer.phar config --list --source` to see where each config value originated from.
2012-08-27 15:46:40 +00:00
## Memory limit errors
2012-08-24 09:53:02 +00:00
2021-11-11 13:58:43 +00:00
The first thing to do is to make sure you are running Composer 2, and if possible 2.2.0 or above.
Composer 1 used much more memory and upgrading to the latest version will give you much better and faster results.
2016-12-02 17:26:07 +00:00
Composer may sometimes fail on some commands with this message:
2012-08-24 09:53:02 +00:00
2014-05-19 10:17:07 +00:00
`PHP Fatal error: Allowed memory size of XXXXXX bytes exhausted <...>`
2012-08-24 09:53:02 +00:00
2016-12-02 17:26:07 +00:00
In this case, the PHP `memory_limit` should be increased.
2012-08-24 09:53:02 +00:00
2017-01-01 21:18:52 +00:00
> **Note:** Composer internally increases the `memory_limit` to `1.5G`.
2012-08-24 13:06:03 +00:00
2012-10-16 18:49:01 +00:00
To get the current `memory_limit` value, run:
2012-08-24 09:53:02 +00:00
2022-08-20 10:23:00 +00:00
```shell
2014-05-19 10:17:07 +00:00
php -r "echo ini_get('memory_limit').PHP_EOL;"
```
2012-08-24 09:53:02 +00:00
2012-10-16 18:49:01 +00:00
Try increasing the limit in your `php.ini` file (ex. `/etc/php5/cli/php.ini` for
2012-08-27 15:46:40 +00:00
Debian-like systems):
2012-08-24 09:53:02 +00:00
2014-05-19 10:17:07 +00:00
```ini
2015-06-11 13:14:45 +00:00
; Use -1 for unlimited or define an explicit value like 2G
2014-05-19 10:17:07 +00:00
memory_limit = -1
```
2012-08-24 09:53:02 +00:00
2018-03-05 08:38:22 +00:00
Composer also respects a memory limit defined by the `COMPOSER_MEMORY_LIMIT` environment variable:
2022-08-20 10:23:00 +00:00
```shell
2018-03-05 08:38:22 +00:00
COMPOSER_MEMORY_LIMIT=-1 composer.phar < ... >
```
2012-10-16 18:49:01 +00:00
Or, you can increase the limit with a command-line argument:
2012-08-24 09:53:02 +00:00
2022-08-20 10:23:00 +00:00
```shell
2014-05-19 10:17:07 +00:00
php -d memory_limit=-1 composer.phar < ... >
```
2012-08-24 09:53:02 +00:00
2017-12-29 10:37:42 +00:00
This issue can also happen on cPanel instances, when the shell fork bomb protection is activated. For more information, see the [documentation ](https://documentation.cpanel.net/display/68Docs/Shell+Fork+Bomb+Protection ) of the fork bomb feature on the cPanel site.
2015-11-21 20:06:31 +00:00
2021-11-11 13:58:43 +00:00
2016-12-28 12:13:23 +00:00
## Xdebug impact on Composer
2019-11-03 13:04:38 +00:00
To improve performance when the Xdebug extension is enabled, Composer automatically restarts PHP without it.
2016-12-28 12:13:23 +00:00
You can override this behavior by using an environment variable: `COMPOSER_ALLOW_XDEBUG=1` .
2016-12-28 15:22:00 +00:00
2019-11-03 13:04:38 +00:00
Composer will always show a warning if Xdebug is being used, but you can override this with an environment variable:
2016-12-28 15:22:00 +00:00
`COMPOSER_DISABLE_XDEBUG_WARN=1` . If you see this warning unexpectedly, then the restart process has failed:
please report this [issue ](https://github.com/composer/composer/issues ).
2016-12-28 12:13:23 +00:00
2021-11-11 13:58:43 +00:00
2013-01-27 22:07:01 +00:00
## "The system cannot find the path specified" (Windows)
1. Open regedit.
2015-01-20 09:55:18 +00:00
2. Search for an `AutoRun` key inside `HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor` ,
`HKEY_CURRENT_USER\Software\Microsoft\Command Processor`
or `HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Command Processor` .
2021-12-19 14:15:21 +00:00
3. Check if it contains any path to a non-existent file, if it's the case, remove them.
2014-01-15 17:17:31 +00:00
2021-11-11 13:58:43 +00:00
2014-01-31 16:33:47 +00:00
## API rate limit and OAuth tokens
2014-01-15 17:17:31 +00:00
Because of GitHub's rate limits on their API it can happen that Composer prompts
for authentication asking your username and password so it can go ahead with its work.
2014-01-31 16:36:00 +00:00
If you would prefer not to provide your GitHub credentials to Composer you can
2020-10-13 21:30:47 +00:00
manually create a token using the [procedure documented here ](authentication-for-private-packages.md#github-oauth ).
2014-01-15 17:17:31 +00:00
Now Composer should install/update without asking for authentication.
2014-02-24 08:40:02 +00:00
2021-11-11 13:58:43 +00:00
2014-02-24 08:40:02 +00:00
## proc_open(): fork failed errors
2021-11-11 13:58:43 +00:00
2021-10-25 11:11:56 +00:00
If Composer shows proc_open() fork failed on some commands:
2014-02-24 08:40:02 +00:00
2014-05-19 10:17:07 +00:00
`PHP Fatal error: Uncaught exception 'ErrorException' with message 'proc_open(): fork failed - Cannot allocate memory' in phar`
2014-02-24 08:40:02 +00:00
This could be happening because the VPS runs out of memory and has no Swap space enabled.
2022-08-20 10:23:00 +00:00
```shell
2014-05-19 10:17:07 +00:00
free -m
2022-08-20 10:23:00 +00:00
```
```text
2014-05-19 10:17:07 +00:00
total used free shared buffers cached
Mem: 2048 357 1690 0 0 237
-/+ buffers/cache: 119 1928
Swap: 0 0 0
```
2014-02-24 08:40:02 +00:00
To enable the swap you can use for example:
2022-08-20 10:23:00 +00:00
```shell
2014-05-19 10:17:07 +00:00
/bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
/sbin/mkswap /var/swap.1
2020-10-22 17:50:35 +00:00
/bin/chmod 0600 /var/swap.1
2014-05-19 10:17:07 +00:00
/sbin/swapon /var/swap.1
```
2016-11-23 11:05:55 +00:00
You can make a permanent swap file following this [tutorial ](https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04 ).
2015-07-20 16:31:45 +00:00
2021-11-11 13:58:43 +00:00
2019-10-08 13:46:37 +00:00
## proc_open(): failed to open stream errors (Windows)
2021-10-25 11:11:56 +00:00
If Composer shows proc_open(NUL) errors on Windows:
2019-10-08 13:46:37 +00:00
`proc_open(NUL): failed to open stream: No such file or directory`
This could be happening because you are working in a _OneDrive_ directory and
using a version of PHP that does not support the file system semantics of this
service. The issue was fixed in PHP 7.2.23 and 7.3.10.
Alternatively it could be because the Windows Null Service is not enabled. For
more information, see this [issue ](https://github.com/composer/composer/issues/7186#issuecomment-373134916 ).
2021-11-11 13:58:43 +00:00
2015-07-20 16:31:45 +00:00
## Degraded Mode
Due to some intermittent issues on Travis and other systems, we introduced a
degraded network mode which helps Composer finish successfully but disables
a few optimizations. This is enabled automatically when an issue is first
2015-07-20 16:50:56 +00:00
detected. If you see this issue sporadically you probably don't have to worry
(a slow or overloaded network can also cause those time outs), but if it
appears repeatedly you might want to look at the options below to identify
and resolve it.
2015-07-20 16:31:45 +00:00
If you have been pointed to this page, you want to check a few things:
- If you are using ESET antivirus, go in "Advanced Settings" and disable "HTTP-scanner"
under "web access protection"
- If you are using IPv6, try disabling it. If that solves your issues, get in touch
with your ISP or server host, the problem is not at the Packagist level but in the
routing rules between you and Packagist (i.e. the internet at large). The best way to get
2021-11-17 10:03:48 +00:00
these fixed is to raise awareness to the network engineers that have the power to fix it.
2016-01-27 11:41:08 +00:00
Take a look at the next section for IPv6 workarounds.
2015-07-20 16:31:45 +00:00
- If none of the above helped, please report the error.
2016-02-20 18:56:22 +00:00
2021-11-11 13:58:43 +00:00
2016-01-27 11:41:08 +00:00
## Operation timed out (IPv6 issues)
You may run into errors if IPv6 is not configured correctly. A common error is:
2022-08-20 10:23:00 +00:00
```text
2016-02-20 18:56:22 +00:00
The "https://getcomposer.org/version" file could not be downloaded: failed to
open stream: Operation timed out
2016-01-27 11:41:08 +00:00
```
2016-02-20 18:56:22 +00:00
We recommend you fix your IPv6 setup. If that is not possible, you can try the
following workarounds:
2016-01-27 11:41:08 +00:00
**Workaround Linux:**
2016-02-20 18:56:22 +00:00
On linux, it seems that running this command helps to make ipv4 traffic have a
2021-12-19 14:15:21 +00:00
higher priority than ipv6, which is a better alternative than disabling ipv6 entirely:
2016-01-27 11:41:08 +00:00
2022-08-20 10:23:00 +00:00
```shell
2016-01-27 11:41:08 +00:00
sudo sh -c "echo 'precedence ::ffff:0:0/96 100' >> /etc/gai.conf"
```
**Workaround Windows:**
On windows the only way is to disable ipv6 entirely I am afraid (either in windows or in your home router).
**Workaround Mac OS X:**
Get name of your network device:
2022-08-20 10:23:00 +00:00
```shell
2016-01-27 11:41:08 +00:00
networksetup -listallnetworkservices
```
2016-02-20 18:56:22 +00:00
Disable IPv6 on that device (in this case "Wi-Fi"):
2016-01-27 11:41:08 +00:00
2022-08-20 10:23:00 +00:00
```shell
2016-01-27 11:41:08 +00:00
networksetup -setv6off Wi-Fi
```
2021-10-25 11:11:56 +00:00
Run Composer ...
2016-01-27 11:41:08 +00:00
You can enable IPv6 again with:
2022-08-20 10:23:00 +00:00
```shell
2016-01-27 11:41:08 +00:00
networksetup -setv6automatic Wi-Fi
```
2016-02-20 18:56:22 +00:00
That said, if this fixes your problem, please talk to your ISP about it to
2021-12-19 14:15:21 +00:00
try to resolve the routing errors. That's the best way to get things resolved
2016-02-20 18:56:22 +00:00
for everyone.
2016-02-22 10:18:57 +00:00
2021-11-11 13:58:43 +00:00
2016-02-22 10:18:57 +00:00
## Composer hangs with SSH ControlMaster
2016-02-25 15:44:15 +00:00
When you try to install packages from a Git repository and you use the `ControlMaster`
2018-03-23 10:37:33 +00:00
setting for your SSH connection, Composer might hang endlessly and you see a `sh`
2016-07-19 09:35:50 +00:00
process in the `defunct` state in your process list.
2016-02-22 10:18:57 +00:00
The reason for this is a SSH Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=1988
As a workaround, open a SSH connection to your Git host before running Composer:
2022-08-20 10:23:00 +00:00
```shell
2016-02-22 10:18:57 +00:00
ssh -t git@mygitserver.tld
2021-10-25 11:11:35 +00:00
php composer.phar update
2016-02-22 10:18:57 +00:00
```
See also https://github.com/composer/composer/issues/4180 for more information.
2016-02-26 07:38:39 +00:00
2021-11-11 13:58:43 +00:00
2016-03-11 09:37:00 +00:00
## Zip archives are not unpacked correctly.
2016-02-26 07:38:39 +00:00
2021-11-11 13:58:43 +00:00
Composer can unpack zipballs using either a system-provided `unzip` or `7z` (7-Zip) utility, or PHP's
native `ZipArchive` class. On OSes where ZIP files can contain permissions and symlinks, we recommend
installing `unzip` or `7z` as these features are not supported by `ZipArchive` .
2020-10-01 14:42:02 +00:00
## Disabling the pool optimizer
In Composer, the `Pool` class contains all the packages that are relevant for the dependency
resolving process. That is what is used to generate all the rules which are then
passed on to the dependency solver.
In order to improve performance, Composer tries to optimize this `Pool` by removing useless
package information early on.
If all goes well, you should never notice any issues with it but in case you run into
an unexpected result such as an unresolvable set of dependencies or conflicts where you
think Composer is wrong, you might want to disable the optimizer by using the environment
variable `COMPOSER_POOL_OPTIMIZER` and run the update again like so:
2022-08-20 10:23:00 +00:00
```shell
2020-10-01 14:42:02 +00:00
COMPOSER_POOL_OPTIMIZER=0 php composer.phar update
```
Now double check if the result is still the same. It will take significantly longer and use
a lot more memory to run the dependency resolving process.
If the result is different, you likely hit a problem in the pool optimizer.
Please [report this issue ](https://github.com/composer/composer/issues ) so it can be fixed.