Ошибка при установке composer

  • General
  • Package not found
  • Package is not updating to the expected version
  • Dependencies on the root package
  • Network timeout issues, curl error
  • Package not found in a Jenkins-build
  • I have a dependency which contains a «repositories» definition in its composer.json, but it seems to be ignored.
  • I have locked a dependency to a specific commit but get unexpected results.
  • Need to override a package version
  • Figuring out where a config value came from
  • Memory limit errors
  • Xdebug impact on Composer
  • «The system cannot find the path specified» (Windows)
  • API rate limit and OAuth tokens
  • proc_open(): fork failed errors
  • proc_open(): failed to open stream errors (Windows)
  • Degraded Mode
  • Operation timed out (IPv6 issues)
  • Composer hangs with SSH ControlMaster
  • Zip archives are not unpacked correctly.
  • Disabling the pool optimizer

This is a list of common pitfalls on using Composer, and how to avoid them.

General#

  1. When facing any kind of problems using Composer, be sure to work with the
    latest version
    . See self-update for details.

  2. Before asking anyone, run composer diagnose to check
    for common problems. If it all checks out, proceed to the next steps.

  3. Make sure you have no problems with your setup by running the installer’s
    checks via curl -sS https://getcomposer.org/installer | php -- --check.

  4. Try clearing Composer’s cache by running composer clear-cache.

  5. Ensure you’re installing vendors straight from your composer.json via
    rm -rf vendor && composer update -v when troubleshooting, excluding any
    possible interferences with existing vendor installations or composer.lock
    entries.

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
    minimum-stability
    . To get started or be
    sure this is no issue, set minimum-stability to «dev».

  3. Packages not coming from Packagist should
    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.

  5. If you are updating to a recently published version of a package, be aware that
    Packagist has a delay of up to 1 minute before new packages are visible to Composer.

  6. If you are updating a single package, it may depend on newer versions itself.
    In this case add the --with-dependencies argument or add all dependencies which
    need an update to the command.

Package is not updating to the expected version#

Try running php composer.phar why-not [package-name] [expected-version].

Dependencies on the root package#

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 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.

  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.
    The best solution is to define the version you are on via an environment variable
    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.

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.

Package not found in a Jenkins-build#

  1. Check the «Package not found» item above.

  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.
    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.

I have a dependency which contains a «repositories» definition in its composer.json, but it seems to be ignored.#

The repositories configuration property is defined as root-only. It is not inherited. You can read more about the reasons behind this in the «why can’t
Composer load repositories recursively?» article.
The simplest work-around to this limitation, is moving or duplicating the repositories definition into your root
composer.json.

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
caveats that one should take into account. The most important one is documented, but
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.

There is no simple work-around to this limitation. It is therefore strongly recommended that you do not use it.

Need to override a package version#

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).

You can fix this by aliasing version 0.11 to 0.1:

composer.json:

{
    "require": {
        "A": "0.2",
        "B": "0.11 as 0.1"
    }
}

See aliases for more information.

Figuring out where a config value came from#

Use php composer.phar config --list --source to see where each config value originated from.

Memory limit errors#

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.

Composer may sometimes fail on some commands with this message:

PHP Fatal error: Allowed memory size of XXXXXX bytes exhausted <...>

In this case, the PHP memory_limit should be increased.

Note: Composer internally increases the memory_limit to 1.5G.

To get the current memory_limit value, run:

php -r "echo ini_get('memory_limit').PHP_EOL;"

Try increasing the limit in your php.ini file (ex. /etc/php5/cli/php.ini for
Debian-like systems):

; Use -1 for unlimited or define an explicit value like 2G
memory_limit = -1

Composer also respects a memory limit defined by the COMPOSER_MEMORY_LIMIT environment variable:

COMPOSER_MEMORY_LIMIT=-1 composer.phar <...>

Or, you can increase the limit with a command-line argument:

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 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, 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.

«The system cannot find the path specified» (Windows)#

  1. Open regedit.
  2. Search for an AutoRun key inside HKEY_LOCAL_MACHINESoftwareMicrosoftCommand Processor,
    HKEY_CURRENT_USERSoftwareMicrosoftCommand Processor
    or HKEY_LOCAL_MACHINESoftwareWow6432NodeMicrosoftCommand Processor.
  3. Check if it contains any path to a non-existent file, if it’s the case, remove them.

API rate limit and OAuth tokens#

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.

If you would prefer not to provide your GitHub credentials to Composer you can
manually create a token using the procedure documented here.

Now Composer should install/update without asking for authentication.

proc_open(): fork failed errors#

If Composer shows proc_open() fork failed on some commands:

PHP Fatal error: Uncaught exception 'ErrorException' with message 'proc_open(): fork failed - Cannot allocate memory' in phar

This could be happening because the VPS runs out of memory and has no Swap space enabled.

free -m
total used free shared buffers cached
Mem: 2048 357 1690 0 0 237
-/+ buffers/cache: 119 1928
Swap: 0 0 0

To enable the swap you can use for example:

/bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
/sbin/mkswap /var/swap.1
/bin/chmod 0600 /var/swap.1
/sbin/swapon /var/swap.1

You can make a permanent swap file following this tutorial.

proc_open(): failed to open stream errors (Windows)#

If Composer shows proc_open(NUL) errors on Windows:

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.

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
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.

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 to raise awareness to the network engineers that have the power to fix it.
    Take a look at the next section for IPv6 workarounds.
  • If none of the above helped, please report the error.

Operation timed out (IPv6 issues)#

You may run into errors if IPv6 is not configured correctly. A common error is:

The "https://getcomposer.org/version" file could not be downloaded: failed to
open stream: Operation timed out

We recommend you fix your IPv6 setup. If that is not possible, you can try the
following workarounds:

Workaround Linux:

On linux, it seems that running this command helps to make ipv4 traffic have a
higher priority than ipv6, which is a better alternative than disabling ipv6 entirely:

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:

networksetup -listallnetworkservices

Disable IPv6 on that device (in this case «Wi-Fi»):

networksetup -setv6off Wi-Fi

Run Composer …

You can enable IPv6 again with:

networksetup -setv6automatic Wi-Fi

That said, if this fixes your problem, please talk to your ISP about it to
try to resolve the routing errors. That’s the best way to get things resolved
for everyone.

Composer hangs with SSH ControlMaster#

When you try to install packages from a Git repository and you use the ControlMaster
setting for your SSH connection, Composer might hang endlessly and you see a sh
process in the defunct state in your process list.

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:

ssh -t git@mygitserver.tld
php composer.phar update

See also https://github.com/composer/composer/issues/4180 for more information.

Zip archives are not unpacked correctly.#

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.

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:

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 so it can be fixed.

Found a typo? Something is wrong in this documentation?
Fork and edit it!

For the sake of google indexing,

I write the error I had

If Composer doesn’t install in windows 7, 8, 10 with php provided in the xampp installation with this error message

The PHP exe file you specified did not run correctly:
yourPathTophp.exe

The program failed to run correctly. Try reinstalling the program to fix this problem. Make sure you have installed the appropriate Visual C++ Redistributable.

The Composer message really confused me for the part of Visual C++, in fact it was not the case

Well, after long searches, I finally have found the Sarim’ solution that you find in this same thread
Composer setup installation error

This specific issue is due to the php.ini which is default provided by the xampp installation which as highlighted by Sarim, does have paths relative to xampp installation and won’t allow Composer-Setup.exe to properly run.

I already uncommented in php.ini:

[PHP]

;;;;;;;;;;;;;;;;;;;
 ; About php.ini ;
;;;;;;;;;;;;;;;;;;;

;extension=php_oci8_11g.dll
extension=php_openssl.dll
;extension=php_pdo_firebird.dll

Variables of the system set ok.

PHP version 5.4.16:

  C:wampbinphpphp5.4.16php.exe

Add to System path variable:

  C:ProgramDataComposerSetupbin

But, recive this error:

Some settings on your machine make Composer unable to work properly.
Make sure that you fix the issues listed below and run this script again:

The openssl extension is missing, which means that secure HTTPS transfers are
impossible. If possible you should enable it or recompile php with --with-openssl

I’m using:

  • windows 7
  • Wamp
  • php 5.1.16
  • apache 2.4.4

How solve this problem, please help me.

jww's user avatar

jww

96.7k90 gold badges407 silver badges878 bronze badges

asked Mar 31, 2014 at 13:54

diangelisj's user avatar

3

  1. Open php.ini located in your «php» folder for example in xampp the file is in XYZ:xamppphp

  2. Find "extension=php_openssl.dll"

  3. ";extension=php_openssl.dll" — remove ";"

  4. Restart your xampp (or whatever u use), extension should be loaded after that.

  5. Try agien to install composer.

answered Apr 2, 2014 at 6:44

jtmielczarek's user avatar

3

ensure you are editing the php.ini locate on same place where is located php.exe, i was the same problem and wamp say the openssl is actived but Composer-Setup.exe used the php.ini in php directory/ext/ and wamp used C:System…php.ini,

Regards,

answered Aug 8, 2014 at 21:31

BrianPando's user avatar

BrianPandoBrianPando

1171 silver badge4 bronze badges

1

I have battled this several times. And this is the best solution I have found.

As mentioned, you need to ensure that extension=php_openssl.dll is enabled but doing just that sometimes may not resolve the error.

You should check that you have PHP on your path variable then see what INI file is loaded by typing php --ini in the console it should give you something like:

Configuration File (php.ini) Path: C:WINDOWS
Loaded Configuration File:         C:WINDOWSphp.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)

Make sure you are enabling the settings in the correct ini file. If you dont have an ini file loaded put an ini file from the php directory into c:windows.

Also important
I find it helps to change the extension_dir flag to an absolute path from relative to makesure the system can find php_opensll.dll.

To do this uncomment the line starting extension_dir and change it to match from the drive root.

Example: C:phpext instead of ext/

answered Feb 19, 2015 at 9:09

Kiee's user avatar

KieeKiee

10.6k8 gold badges30 silver badges56 bronze badges

1

For MAMP users, this is what worked for me.

If your php.ini is located under a MAMPconf

  1. copy the php.ini into aMAMPbinphpphp[your PHP version number]
  2. Restart MAMP and the command-line window
  3. Go to a directory under a command-line window where you want to install composer
  4. run from a command line:
    php -r «readfile(‘http://getcomposer.org/installer’);» | php

NOTE: it is http not https !

END

answered Dec 2, 2014 at 23:30

3xCh1_23's user avatar

3xCh1_233xCh1_23

1,4731 gold badge20 silver badges39 bronze badges

1

I figured it out and successfully installed Composer in My windows 10 PC.

I am sharing two solutions here.

There are some steps you have to follow in order to solve your problem.

1st solution.

  1. Find and Open php.ini located in your «php» folder In my case it is in xampp the file is in c:xamppphp
  2. Find "extension=php_openssl.dll"
  3. ";extension=php_openssl.dll" uncomment by removing the semicolon ";"
  4. Restart your xampp , now extension should be loaded after that.
  5. Try again now you are able to install composer.

2nd solution(If the above solution not work for you then go with below solution . )

This works in my case

  1. Find and Open php.ini located in your «php» folder In my case it is in xampp the file is in c:xamppphp
  2. Open SHELL from Xampp start panel by clicking on shell button.
  3. Write php in shell and hit enter
  4. If you get some waring message in your shell something like below .
    enter image description here
  5. Then you have to fix these waring message by commenting all these extension in your php.ini file.(Actually cause of these warning messages are because more than one time these extensions are enabled but you can un-comment it in php.ini file for solving the issue).

    For Example which is in my case.

    a). You can see in above image there is warning message for curl.

    Module 'curl' already loaded in Unknown on line 0 .
    

    b) To fix this find php_curl.dll file in your php.ini file and comment that extension by adding semicolon ";" in front of that extension like this ;extension=php_curl.dll

Follow above steps if you have more than one warning for each extension untill you are not getting any warning message in your shell.

  1. Restart your xampp , now extension should be loaded after that.
  2. Try again now you are able to install composer.

Hope I can solve your issue .

That’s all folks . Happy coding !!! (amitamie.com) :-) ;-)

answered Mar 3, 2017 at 11:23

Amit Kumar's user avatar

Amit KumarAmit Kumar

7677 silver badges10 bronze badges

The problem solved after turn off windows firewall.

installation complete!

answered Mar 31, 2014 at 15:16

diangelisj's user avatar

diangelisjdiangelisj

1671 gold badge2 silver badges4 bronze badges

I nearly wrapped my head off trying to install composer on my windows 7 machine.

I was trying to install composer through the composer installer from getcomposer.org.

After the common openssl extension enabling (As above answers describing).

The installer has finished the installation successfully. But calling composer on the command line, wasnt
possible. It was telling me composer / application not found, check for typos etc…

Cant getting it running, I looked at the manually install guide and noticed something weird.

The doc said: «Close your current terminal. Test usage with a new terminal:»

I closed my terminal window. Opened a new one and IT WORKED!!!

I had a terminal window open during the composer installation. After that I was trying to call composer via the command line in this terminal. This didnt work.

So why did it not work?
The composer installer downloads the composer.phar file and sets a environment path to it. The terminal only gets the environment PATHS, when it gets started. So of course the path wasnt set for the terminal.

Solution:

If you have a terminal open before the installation just close it and open a new terminal window to get composer ready to use!!!

I hope I can save someone a couple hours of living time.

answered Nov 25, 2014 at 15:51

PaulSchell's user avatar

PaulSchellPaulSchell

1822 silver badges10 bronze badges

answered May 8, 2015 at 10:22

Chirag Parekh's user avatar

  1. Find a php.ini in C:wampbinphpphp5.4.16 (the configuration file of PHP).
  2. Remove ; in lines ;extension=php_openssl.dll and ;extension_dir = "ext". PHP will know that you are using a php_openssl extension and extension_dir is the location of extensions (you can see it in the comment above php_openssl).
  3. Run the Windows command prompt with administrator permissions.
  4. Execute the following command: mklink C:Windowsphp.ini C:wampbinphpphp5.4.16php.ini

Composer search php.ini in C:Windowsphp.ini and you have your PHP in WAMP. With mklink command you create a link php.ini that aim to your WAMP’s php.ini.

answered Jul 29, 2015 at 10:02

Olek's user avatar

OlekOlek

1066 bronze badges

2

i was facing the same issue but i fixed that,

if you are using wamp

goto your selected php version directory and then you need to edit that directory php.ini file

replace this line ;extension=php_openssl.dll to extension=php_openssl.dll and save and then restart then it will be working :)

answered May 30, 2014 at 10:12

Ahmer's user avatar

AhmerAhmer

945 bronze badges

I was facing the same issue in windows 7 PC with xampp.

Cannot open ‘xamppphpextrasbrowscap.ini’ for reading in Unknown on line 0

I just change the value of ‘browscap’ in php.ini file. Use full path instead of absolute path.

In my case Xampp was in E drive so I have changed
browscap=»xamppphpextrasbrowscap.ini»
to
browscap=»E:xamppphpextrasbrowscap.ini»

And it works for me!

Tonechas's user avatar

Tonechas

13.3k15 gold badges45 silver badges80 bronze badges

answered Jan 8, 2017 at 18:49

Sumon's user avatar

SumonSumon

414 bronze badges

I cleaned up a bit on my test machine and can reproduce it now indeed. I’ve also found the issue (after a freaking hour of notepad-debugging), in https://github.com/composer/windows-setup/blob/master/src/composer.iss#L1881

What happens: the specific combination of enabling the openssl DLL, but at the incorrect path, causes a startup error as quoted a few issues back, and as we both renamed php.ini-development the value for display_startup_errors is on. So setup.php is executed, and it finds the system perfectly capable of running Composer so it gives return code 0. BUT, the first line of output is not a GUID with a PHP-version behind in this case:

$ cmd /c "C:Program FilesPHP5.6php.exe" setup.php -- --php
PHP Warning:  PHP Startup: Unable to load dynamic library 'C:phpphp_openssl.dll' - The specified module could not be found.
 in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'C:phpphp_openssl.dll' - The specified module could not be found.
 in Unknown on line 0
3ECDC245-751A-4962-B580-B8A250EDD1CF5.6.15

So these rules kick in next:

  {
   * Possible errors:
   * Internal error - cmd did not run [ERR_CMD]
   * Internal error - cmd did not create output file run [ERR_CMD_EX]
   * ExitCode: 0 - Php check passed
   * ExitCode: 1 - Php check failed
   * ExitCode: ? - Php program error [ERR_STATUS] (Test=p1, Test=p2)
   * Results file, empty: [ERR_RESULT] (Test=p3)
   * Results file, non-matching guid: [ERR_INVALID] (Test=p4)
   * Results file, ExitCode 0, multiline [ERR_LOGIC] (test=p5)
   * Results file, ExitCode 1, guid only [ERR_LOGIC] (test=p6)
  }

ExitCode 0 says the PHP check passed, but the Results file does not match the GUID, hence the cryptic ERR_INVALID we’re seeing without any extra information — nothing went wrong technically apart from unexpected sparse output.

The problem is that this needs 2 fixes, and I can only confidently do one of them:

  1. setup.php has to check for openssl to be installed (it would cause exit code 1 and thus the real non-cryptic output to be displayed)
  2. The installer has to better handle unexpected startup errors, as now any thorough PHP misconfiguration will cause this vague output. My Inno Setup skills are zilch so this isn’t on me.

Pinging @johnstevenson in here as he might be able to fix the second one, and I can’t build or deploy the installer anyway.

Всем привет хотел установить Composer но пишет эту ошибку никак не могу решить.
5fb4e9bf99e66753620887.png
Если что дополнительно пишу код ошибки.

The PHP exe file you specified did not run correctly:
C:Program FilesPhpphp.exe

The php.ini used by your command-line PHP is: C:Program FilesPhpphp.ini

A setting in your php.ini could be causing the problem: Either the ‘extension_dir’ value is incorrect or a dll does not exist.

Program Output:
PHP Warning: PHP Startup: Unable to load dynamic library ‘pdo_firebird’ (tried: extpdo_firebird (The specified module could not be found.), extphp_pdo_firebird.dll (The specified module could not be found.)) in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘pdo_oci’ (tried: extpdo_oci (The specified module could not be found.), extphp_pdo_oci.dll (The specified module could not be found.)) in Unknown on line 0

Понравилась статья? Поделить с друзьями:
  • Ошибка при установке civilization 6
  • Ошибка при установке cisco anyconnect
  • Ошибка при установке camera raw
  • Ошибка при установке call of duty ww2
  • Ошибка при установке call of duty warzone