溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

如何理解composer的錯(cuò)誤

發(fā)布時(shí)間:2021-11-09 17:16:52 來源:億速云 閱讀:261 作者:柒染 欄目:軟件技術(shù)

如何理解composer的錯(cuò)誤,很多新手對此不是很清楚,為了幫助大家解決這個(gè)難題,下面小編將為大家詳細(xì)講解,有這方面需求的人可以來學(xué)習(xí)下,希望你能有所收獲。

composer遇到的錯(cuò)誤匯集

1#權(quán)限錯(cuò)誤

file_put_contents(/home/vagrant/.composer/cache/repo/https---packagist.laravel-china.org/packages.json): failed to open stream: Permission denied
https://packagist.laravel-china.org could not be fully loaded, package information was loaded from the local cache and may be out of date

解決方法:sudo chown -R $USER ~/.composer/

2# zlib_decode():data error

Failed to decode response: zlib_decode(): data error
Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info

解決方法 更換composer的repo.packagist

3# SSL routines:ssl3_get_server_certificate:certificate verify failed

錯(cuò)誤描述

- Installing phpunit/phpunit (6.5.8): Downloading (failed)
Downloading (failed)
Downloading (failed)    Failed to download phpunit/phpunit from dist: The "https://files.phpcomposer.com/files/sebastianbergmann/phpunit/4f21a3c6b97c42952fd5c2837bb354ec0199b97b.zip" file could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed
Failed to enable crypto
failed to open stream: operation failed
    Now trying to download from source

解決方案

In my case, it was the CA Cert file that was the culprit
Open terminal and run php -r "var_dump(openssl_get_cert_locations());"
Note the location of default_cert_file. It might say \usr\local\ssl\cert.pem
Verify that that file exists. If not, download the cacert.pem file from https://curl.haxx.se/ca/cacert.pem and place it in somewhere preferably in /usr/local/ssl
You now have a file is usr/local/ssl/cacert.pem
Open your php.ini and add the location of the file openssl.cafile=cacert.pem
Run composer config --global cafile "/usr/local/ssl/cacert.pem"
If it's of any use to others, I use valet+ 1.0.26, composer 1.8.4 OSX Movajes 10.14.3, php7.3 and simply specifying the cert composer looks for with:
composer config --global cafile "/usr/local/etc/openssl/cert.pem"
composer config --global cafile "C:/AMP_ENV/php-7.1.15/ca/cacert.pem"
composer config --global --list

4# proc_open(): fork failed - Cannot allocate memory

錯(cuò)誤描述

Installation failed, reverting ./composer.json to its original content.
The following exception is caused by a lack of memory or swap, or not having swap configured
Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details
PHP Warning:  proc_open(): fork failed - Cannot allocate memory in phar:///usr/local/bin/composer/vendor/symfony/console/Application.php on line 952
Warning: proc_open(): fork failed - Cannot allocate memory in phar:///usr/local/bin/composer/vendor/symfony/console/Application.php on line 952
  [ErrorException]
  proc_open(): fork failed - Cannot allocate memory

解決方式

sudo dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
sudo mkswap /var/swap.1
sudo swapon /var/swap.1

5# 執(zhí)行 composer 拋出 Killed

錯(cuò)誤描述

root@test2:/work/usrc$ composer require qcloud/cos-sdk-v5
./composer.json has been updated
The "extra.asset-installer-paths" option is deprecated, use the "config.fxp-asset.installer-paths" option
Loading composer repositories with package information
Updating dependencies (including require-dev)
Killed

解決方式

出現(xiàn)此原因大多因?yàn)榫彺娌蛔阍斐?,在linux環(huán)境可增加緩存解決。

free -m
sudo mkdir -p /var/_swap_
cd /var/_swap_
sudo dd if=/dev/zero of=swapfile bs=1M count=2000
sudo mkswap swapfile
sudo swapon swapfile
sudo echo "/var/_swap_/swapfile none swap sw 0 0" >> /etc/fstab
free -m

看完上述內(nèi)容是否對您有幫助呢?如果還想對相關(guān)知識有進(jìn)一步的了解或閱讀更多相關(guān)文章,請關(guān)注億速云行業(yè)資訊頻道,感謝您對億速云的支持。

向AI問一下細(xì)節(jié)
推薦閱讀:
  1. composer
  2. composer的使用

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI