【问题标题】:Unable to run composer install无法运行作曲家安装
【发布时间】:2015-10-23 00:33:04
【问题描述】:

我正在尝试在我的项目中运行 composer install 但出现以下错误

[Composer\Downloader\TransportException]
The "http://packagist.org/p/provider-2013$43e3f41fbe30a46245103451248f688a727f076a6e90636d19a69a156c17a416.json" file could not be downloaded (HTTP/1.1 400 Received invalid request from Client)

我尝试运行 composer self-update 并出现此错误

[Composer\Downloader\TransportException]
The "https://getcomposer.org/version" file could not be downloaded: Failed to enable crypto failed to open stream: operation failed

我在代理后面运行 Ubuntu 15.04 和 apache/php5.6.4/mysql。

我已尝试下载 http://curl.haxx.se/ca/cacert.pem 并使用以下内容更新了我的 php.ini 文件

curl.cainfo=/etc/ssl/certs/cacert.pem
openssl.cafile=/etc/ssl/certs/cacert.pem
openssl.capath=/etc/ssl/certs

运行 composer diagnostic 会返回这个

Checking composer.json: OK
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: FAIL
[Composer\Downloader\TransportException] The "http://packagist.org/packages.json" file could not be downloaded (HTTP/1.1 400 Received invalid request from Client)
Checking https connectivity to packagist: OK
Checking HTTP proxy: OK
Checking HTTP proxy support for request_fulluri: FAIL
Unable to assess the situation, maybe packagist.org is down (The "http://packagist.org/packages.json" file could not be downloaded (HTTP/1.1 400 Received invalid request from Client))
Checking HTTPS proxy support for request_fulluri: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking composer version: FAIL
You are not running the latest version

最后 openssl_get_cert_locations() 返回

  • default_cert_file: /usr/lib/ssl/cert.pem
  • default_cert_file_env: SSL_CERT_FILE
  • default_cert_dir:/usr/lib/ssl/certs
  • default_cert_dir_env: SSL_CERT_DIR
  • default_private_dir: /usr/lib/ssl/private
  • default_default_cert_area: /usr/lib/ssl
  • ini_cafile: /etc/ssl/certs/cacert.pem
  • ini_capath: /etc/ssl/certs

我完全不知道出了什么问题,更不知道如何调试它。

希望有人能帮帮我!

【问题讨论】:

    标签: php ubuntu composer-php


    【解决方案1】:

    你也一样。我在互联网上找到了解决它的方法(对于窗口 10)。 1 - 转到文件夹 PATH\xampp\apache 并运行 makecert.bat 2 - 将此脚本添加到 composer.json 文件中

    "repositories": [
            {
                "type": "composer",
                "url": "https://packagist.org"
            },
            {
                "packagist": false
            }
        ]
    

    【讨论】:

    • 谢谢,你救了我,伙计!我花了两个晚上在我愚蠢的 Windows 10 机器上为这个问题寻找解决方案,直到现在都没有希望。我会将您的答案传播到网络上,希望对其他人有所帮助。
    • :) 很高兴为您提供帮助
    【解决方案2】:

    鉴于上述composer diagnose 中的 HTTP 连接测试失败,而 HTTPS 测试通过:该问题很可能与某种 HTTPS 强制有关:

    Checking HTTP connectivity to packagist: FAIL
    ...
    Checking HTTP proxy support for request_fulluri: FAIL
    ...
    Checking HTTPS proxy support for request_fulluri: OK
    

    运行下面的 sn-p(在 composer 上强制使用 HTTPS)为我解决了这个问题:

    composer config -g repo.packagist composer https://packagist.org
    

    Solution Source

    【讨论】:

      【解决方案3】:

      如果你是Linux(Ubuntu)用户则执行以下命令解决:

      php -r "print_r(openssl_get_cert_locations());"
      
      wget http://curl.haxx.se/ca/cacert.pem
      
      sudo mv cacert.pem /usr/lib/ssl/certs/cert.pem // Note: Create the cert.pem file under certs folder if does not exist.
      

      【讨论】:

      • Kamlesh,您能否解释一下第一步 - 如果要替换路径,为什么要检查 openssl 证书的现有位置?还是我应该用 wget 的输出替换 php 命令显示的任何路径?
      【解决方案4】:

      也许您可以尝试更改您的代理。

      http://composer-proxy.jp/

      这是来自日本的代理。希望它对你有用。

      【讨论】:

        【解决方案5】:

        试试php composer global self-update

        【讨论】:

          【解决方案6】:

          在环境中设置代理,在终端中使用:

          export http_proxy=<proxy>:<port>
          export https_proxy=<proxy>:<port>
          

          【讨论】:

            【解决方案7】:

            如果 linux - 服务 iptables 停止

            或关闭Windows上的杀毒、防火墙

            【讨论】:

              【解决方案8】:

              如果以上都不适合您,请尝试删除系统设置“环境变量”的 http_proxy 环境变量

              【讨论】:

                猜你喜欢
                • 2017-08-13
                • 2014-10-12
                • 2023-03-03
                • 2018-04-26
                • 1970-01-01
                • 2017-06-13
                • 1970-01-01
                • 1970-01-01
                • 2016-04-29
                相关资源
                最近更新 更多