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.
|
|
|
|
|
|
|
|
## General
|
|
|
|
|
2013-06-12 12:05:01 +00:00
|
|
|
1. Before asking anyone, run [`composer diagnose`](../03-cli.md#diagnose) to check
|
2013-04-03 22:47:03 +00:00
|
|
|
for common problems. If it all checks out, proceed to the next steps.
|
|
|
|
|
|
|
|
2. 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.
|
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
|
|
|
|
2013-04-03 22:47:03 +00:00
|
|
|
4. 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
|
|
|
|
2014-10-07 13:35:09 +00:00
|
|
|
5. Try clearing Composer's cache by running `composer clear-cache`.
|
2014-07-05 12:53:31 +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
|
|
|
|
2013-02-19 15:18:45 +00:00
|
|
|
## Package not found on travis-ci.org
|
|
|
|
|
|
|
|
1. Check the ["Package not found"](#package-not-found) item above.
|
|
|
|
|
|
|
|
2. If the package tested is a dependency of one of its dependencies (cyclic
|
2015-06-22 09:08:23 +00:00
|
|
|
dependency), the problem might be that Composer is not able to detect the version
|
2013-02-19 15:18:45 +00:00
|
|
|
of the package properly. If it is a git clone it is generally alright and Composer
|
|
|
|
will detect the version of the current branch, but travis does shallow clones so
|
|
|
|
that process can fail when testing pull requests and feature branches in general.
|
|
|
|
The best solution is to define the version you are on via an environment variable
|
|
|
|
called COMPOSER_ROOT_VERSION. You set it to `dev-master` for example to define
|
|
|
|
the root package's version as `dev-master`.
|
2013-01-06 20:00:36 +00:00
|
|
|
Use: `before_script: COMPOSER_ROOT_VERSION=dev-master composer install` to export
|
2013-02-19 15:18:45 +00:00
|
|
|
the variable for the call to composer.
|
2013-01-06 20:00:36 +00:00
|
|
|
|
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.
|
2015-07-20 16:50:34 +00:00
|
|
|
2. Reason for failing is similar to the problem which can occur on travis-ci.org: The
|
|
|
|
git-clone / checkout within Jenkins leaves the branch in a "detached HEAD"-state. As
|
|
|
|
a result, Composer is not able to identify the version of the current checked out branch
|
|
|
|
and may not be able to resolve a cyclic dependency. 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 cyclic
|
2015-06-22 09:08:23 +00:00
|
|
|
dependency is recognized correctly.
|
2015-03-24 08:44:13 +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
|
|
|
|
2012-08-27 15:46:40 +00:00
|
|
|
## Memory limit errors
|
2012-08-24 09:53:02 +00:00
|
|
|
|
|
|
|
If composer shows memory errors on some commands:
|
|
|
|
|
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
|
|
|
|
2015-10-29 12:32:12 +00:00
|
|
|
Check first that XDebug is not loaded in your `php.ini` by running
|
2015-10-29 12:29:33 +00:00
|
|
|
`composer diagnose`. If XDebug is loaded, you should disable it by
|
|
|
|
commenting the line `zend_extension=path/to/xdebug` in your `php.ini`.
|
|
|
|
Don't forget to enable XDebug again after using Composer, if you need it.
|
2015-10-28 19:14:23 +00:00
|
|
|
|
|
|
|
If composer still raises the error, the PHP `memory_limit` should be increased.
|
2012-08-24 09:53:02 +00:00
|
|
|
|
2015-06-11 13:14:45 +00:00
|
|
|
> **Note:** Composer internally increases the `memory_limit` to `1G`.
|
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
|
|
|
|
2014-05-19 10:17:07 +00:00
|
|
|
```sh
|
|
|
|
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
|
|
|
|
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
|
|
|
|
2014-05-19 10:17:07 +00:00
|
|
|
```sh
|
|
|
|
php -d memory_limit=-1 composer.phar <...>
|
|
|
|
```
|
2012-08-24 09:53:02 +00:00
|
|
|
|
2015-11-17 13:05:22 +00:00
|
|
|
## Xdebug impact on Composer
|
|
|
|
|
|
|
|
Running Composer console commands while the php extension "xdebug" is loaded reduces speed considerably.
|
|
|
|
This is even the case when all "xdebug" related features are disabled per php.ini flags,
|
|
|
|
but the php extension itself is loaded into the PHP engine.
|
|
|
|
Compared to a cli command run with "xdebug" enabled a speed improvement by a factor of up to 3 is not uncommon.
|
|
|
|
|
|
|
|
> **Note:** This is a general issue when running PHP with "xdebug" enabled. You shouldn't
|
|
|
|
> load the extension in production like environments per se.
|
|
|
|
|
|
|
|
Disable "xdebug" in your `php.ini` (ex. `/etc/php5/cli/php.ini` for Debian-like systems) by
|
|
|
|
locating the related `zend_extension` directive and prepending it with `;` (semicolon):
|
|
|
|
|
|
|
|
```sh
|
|
|
|
;zend_extension = "/path/to/my/xdebug.so"
|
|
|
|
```
|
|
|
|
|
2015-11-25 12:58:10 +00:00
|
|
|
If you disable this extension and still want it to be added on `php` cli command, you can deal with aliases on *nix systems:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
# Load xdebug Zend extension with php command
|
|
|
|
alias php='php -dzend_extension=xdebug.so'
|
|
|
|
# PHPUnit needs xdebug for coverage. In this case, just make an alias with php command prefix.
|
|
|
|
alias phpunit='php $(which phpunit)'
|
|
|
|
```
|
|
|
|
|
|
|
|
With that, all php binaries called directly **will not** have xdebug enabled
|
|
|
|
but you will still have it by prefixing them with php command.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
# Will NOT have xdebug enabled
|
|
|
|
composer update
|
|
|
|
# Will have xdebug enabled by alias
|
|
|
|
php /usr/local/bin/composer update
|
|
|
|
```
|
|
|
|
|
2015-11-21 20:06:31 +00:00
|
|
|
If you do not want to disable it and want to get rid of the warning you can also define the
|
|
|
|
[COMPOSER_DISABLE_XDEBUG_WARN](../03-cli.md#composer-disable-xdebug-warn) environment variable.
|
|
|
|
|
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`.
|
2013-01-27 22:07:01 +00:00
|
|
|
3. Check if it contains any path to non-existent file, if it's the case, just remove them.
|
2014-01-15 17:17:31 +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
|
2014-01-31 16:33:13 +00:00
|
|
|
manually create a token using the following procedure:
|
2014-01-15 17:17:31 +00:00
|
|
|
|
2014-01-31 16:33:47 +00:00
|
|
|
1. [Create](https://github.com/settings/applications) an OAuth token on GitHub.
|
2014-01-15 17:17:31 +00:00
|
|
|
[Read more](https://github.com/blog/1509-personal-api-tokens) on this.
|
|
|
|
|
|
|
|
2. Add it to the configuration running `composer config -g github-oauth.github.com <oauthtoken>`
|
|
|
|
|
|
|
|
Now Composer should install/update without asking for authentication.
|
2014-02-24 08:40:02 +00:00
|
|
|
|
|
|
|
## proc_open(): fork failed errors
|
|
|
|
If composer shows proc_open() fork failed on some commands:
|
|
|
|
|
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.
|
|
|
|
|
2014-05-19 10:17:07 +00:00
|
|
|
```sh
|
|
|
|
free -m
|
|
|
|
|
|
|
|
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:
|
|
|
|
|
2014-05-19 10:17:07 +00:00
|
|
|
```sh
|
|
|
|
/bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
|
|
|
|
/sbin/mkswap /var/swap.1
|
|
|
|
/sbin/swapon /var/swap.1
|
|
|
|
```
|
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
|
|
|
|
these fixed is raise awareness to the network engineers that have the power to fix it.
|
|
|
|
|
|
|
|
To disable IPv6 on Linux, try using this command which appends a
|
2015-10-03 20:40:55 +00:00
|
|
|
rule preferring IPv4 over IPv6 to your config:
|
2015-07-20 16:31:45 +00:00
|
|
|
|
|
|
|
`sudo sh -c "echo 'precedence ::ffff:0:0/96 100' >> /etc/gai.conf"`
|
|
|
|
- If none of the above helped, please report the error.
|