From 365e3feba99face4bd4e2bc87998ddd2fed44b78 Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Fri, 2 Dec 2016 18:26:07 +0100 Subject: [PATCH 1/5] [Documentation] Update troubleshooting article - remove the xdebug section, since it will be irrelevant from v1.3 - add cPanel shell fork bomb protection as an other possible root cause of memory errors --- doc/articles/troubleshooting.md | 94 ++------------------------------- 1 file changed, 3 insertions(+), 91 deletions(-) diff --git a/doc/articles/troubleshooting.md b/doc/articles/troubleshooting.md index fcdae24d2..538e05883 100644 --- a/doc/articles/troubleshooting.md +++ b/doc/articles/troubleshooting.md @@ -119,16 +119,11 @@ See [aliases](aliases.md) for more information. ## Memory limit errors -If composer shows memory errors on some commands: +Composer may sometimes fail on some commands with this message: `PHP Fatal error: Allowed memory size of XXXXXX bytes exhausted <...>` -Check first that XDebug is not loaded in your `php.ini` by running -`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. - -If composer still raises the error, the PHP `memory_limit` should be increased. +In this case, the PHP `memory_limit` should be increased. > **Note:** Composer internally increases the `memory_limit` to `1G`. @@ -152,90 +147,7 @@ Or, you can increase the limit with a command-line argument: php -d memory_limit=-1 composer.phar <...> ``` -## 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" -``` - -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 -``` - -Or, you can add aliases for composer to run with an xdebug-disabled `php.ini` file. -Running php without a `php.ini` file should also do the trick in most cases. - -Example: - -```sh -# Without php.ini -alias comp='php -n /path/to/composer.phar' -# Or with an xdebug-disabled php.ini -alias comp='php -c /path/to/xdebug-disabled-php.ini /path/to/composer.phar' -``` - -As a workaround in bash (and other shells) you can create a function which is named `composer`, -which disables xdebug before it executes composer, and then enables it afterwards. - -Create a function in a file read by bash, like `~/.bashrc` or `~/.bash_aliases` depending on -your setup. This also assumes that you have sudo privileges and the `php5enmod` and `php5dismod` -commands available. It also assumes that you have `composer` in your path. - -```sh -echo 'function composer() { COMPOSER="$(which composer)" || { echo "Could not find composer in path" >&2 ; return 1 ; } && sudo php5dismod -s cli xdebug ; $COMPOSER "$@" ; STATUS=$? ; sudo php5enmod -s cli xdebug ; return $STATUS ; }' >> ~/.bash_aliases -. ~/.bash_aliases -``` - -On platforms without `php5enmod` and `php5dismod` you can run: - -```sh -php --ini -``` - -To check where the PHP configuration is, and then use a similar script: - -```sh -mkdir /usr/local/etc/php/7.0/conf.dis -echo 'function composer() { COMPOSER="$(which composer)" || { echo "Could not find composer in path" >&2 ; return 1 ; } && mv /usr/local/etc/php/7.0/conf.d/ext-xdebug.ini /usr/local/etc/php/7.0/conf.dis ; $COMPOSER "$@" ; STATUS=$? ; mv /usr/local/etc/php/7.0/conf.dis/ext-xdebug.ini /usr/local/etc/php/7.0/conf.d ; return $STATUS ; }' >> ~/.bash_aliases -. ~/.bash_aliases -``` - -In the example above, we have PHP 7.0 installed on a Mac with Homebrew (which doesn't have the stated commands and places the configurations on a folder where there is no need for sudo permissions. - -When executing `composer` you will run it with xdebug **disabled** (**as long as the command is executing**), -and if you execute composer using explicit path (like `./composer` or `/usr/local/bin/composer`) -xdebug will be **enabled**. - -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. +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/ALD/Shell+Fork+Bomb+Protection) of the fork bomb feature on the cPanel site. ## "The system cannot find the path specified" (Windows) From 7b966f9355c9948da5ee1b58264e7ad85286a036 Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Tue, 6 Dec 2016 17:48:23 +0100 Subject: [PATCH 2/5] Remove reference to COMPOSER_IGNORE_XDEBUG_WARN --- doc/03-cli.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/doc/03-cli.md b/doc/03-cli.md index 340d2f299..4996c2205 100644 --- a/doc/03-cli.md +++ b/doc/03-cli.md @@ -858,10 +858,6 @@ This env var controls the [`discard-changes`](06-config.md#discard-changes) conf If set to 1, this env var will make Composer behave as if you passed the `--no-interaction` flag to every command. This can be set on build boxes/CI. -### COMPOSER_DISABLE_XDEBUG_WARN - -If set to 1, this env disables the warning about having xdebug enabled. - ### COMPOSER_ALLOW_SUPERUSER If set to 1, this env disables the warning about running commands as root/super user. From 1d2a949e3e1467336cba5a1598b16070d69ebd33 Mon Sep 17 00:00:00 2001 From: AnrDaemon Date: Sat, 24 Dec 2016 03:19:50 +0300 Subject: [PATCH 3/5] Properly fix git excludes. Mindless copy-paste never gets old. Sorry. This is fixed proper this time. --- .../Composer/Test/Downloader/GitDownloaderTest.php | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/tests/Composer/Test/Downloader/GitDownloaderTest.php b/tests/Composer/Test/Downloader/GitDownloaderTest.php index 688b9ceee..ad3cd6666 100644 --- a/tests/Composer/Test/Downloader/GitDownloaderTest.php +++ b/tests/Composer/Test/Downloader/GitDownloaderTest.php @@ -25,19 +25,10 @@ class GitDownloaderTest extends TestCase /** @var string */ private $workingDir; - private $skipped; - - protected function initialize() - { - try { - $this->skipIfNotExecutable('git'); - } catch (\PHPUnit_Framework_SkippedTestError $e) { - $this->skipped = 'This test needs a git binary in the PATH to be able to run'; - } - } - protected function setUp() { + $this->skipIfNotExecutable('git'); + $this->fs = new Filesystem; $this->workingDir = $this->getUniqueTmpDirectory(); } From d57a89d5afac7889cf8cecc37f78fb818d169baf Mon Sep 17 00:00:00 2001 From: johnstevenson Date: Wed, 28 Dec 2016 12:13:23 +0000 Subject: [PATCH 4/5] Update xdebug troubleshooting, fixes #5997 --- doc/articles/troubleshooting.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/articles/troubleshooting.md b/doc/articles/troubleshooting.md index 7376d2ec5..e1e53efd2 100644 --- a/doc/articles/troubleshooting.md +++ b/doc/articles/troubleshooting.md @@ -149,6 +149,13 @@ php -d memory_limit=-1 composer.phar <...> 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/ALD/Shell+Fork+Bomb+Protection) of the fork bomb feature on the cPanel site. +## Xdebug impact on Composer + +To improve performance when the xdebug extension is enabled, Composer automatically restarts PHP without it. +You can override this behavior by using an environment variable: `COMPOSER_ALLOW_XDEBUG=1`. +Composer will always show a warning if xdebug is being used. If you see this unexpectedly, then +the restart process has failed: please report this [issue](https://github.com/composer/composer/issues). + ## "The system cannot find the path specified" (Windows) 1. Open regedit. From 25ff290e4c57604238da56a49fd38186b07231f1 Mon Sep 17 00:00:00 2001 From: johnstevenson Date: Wed, 28 Dec 2016 15:22:00 +0000 Subject: [PATCH 5/5] Document COMPOSER_DISABLE_XDEBUG_WARN variable --- doc/articles/troubleshooting.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/articles/troubleshooting.md b/doc/articles/troubleshooting.md index e1e53efd2..58ac28153 100644 --- a/doc/articles/troubleshooting.md +++ b/doc/articles/troubleshooting.md @@ -153,8 +153,10 @@ This issue can also happen on cPanel instances, when the shell fork bomb protect To improve performance when the xdebug extension is enabled, Composer automatically restarts PHP without it. You can override this behavior by using an environment variable: `COMPOSER_ALLOW_XDEBUG=1`. -Composer will always show a warning if xdebug is being used. If you see this unexpectedly, then -the restart process has failed: please report this [issue](https://github.com/composer/composer/issues). + +Composer will always show a warning if xdebug is being used, but you can override this with an environment variable: +`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). ## "The system cannot find the path specified" (Windows)