配置中的`http-basic`不起作用

时间:2016-07-24 17:17:02

标签: composer-php

我正在使用Composer 1.2.0以及以下文件:

composer.json

{
  "repositories": [
    {
      "type": "composer",
      "url": "https://composer.typo3.org/"
    },
    {
      "type": "vcs",
      "url": "https://sub.domain.com/git/xyz"
    }
  ],
  "require": {
    "typo3/cms": "^7.6.10",
    "vendor/extension": "dev-develop"
  },
  "extra": {
    "typo3/cms": {
      "cms-package-dir": "{$vendor-dir}/typo3/cms",
      "web-dir": "web"
    }
  }
}

auth.json

{
  "http-basic": {
    "sub.domain.com": {
      "username": "user",
      "password": "password"
    }
  }
}

当我执行$ composer install -vvv$ composer update -vvv时,我得到:

Reading ./composer.json
Loading config file /home/user/.composer/config.json
Loading config file /home/user/.composer/auth.json
Loading config file ./composer.json
Loading config file /var/www/html/auth.json
Reading /var/www/html/auth.json
Checked CA file /etc/ssl/certs/ca-certificates.crt: valid
Executing command (/var/www/html): git branch --no-color --no-abbrev -v
Executing command (/var/www/html): git describe --exact-match --tags
Executing command (/var/www/html): git log --pretty="%H" -n1 HEAD
Reading /home/user/.composer/composer.json
Loading config file /home/user/.composer/config.json
Loading config file /home/user/.composer/auth.json
Loading config file /home/user/.composer/composer.json
Loading config file /home/user/.composer/auth.json
Reading /home/user/.composer/auth.json
Reading /var/www/html/vendor/composer/installed.json
Reading /home/user/.composer/vendor/composer/installed.json
Loading plugin TYPO3\CMS\Composer\Installer\Plugin
Loading plugin TYPO3\ClassAliasLoader\Plugin
Loading composer repositories with package information
Downloading https://composer.typo3.org/packages.json
Writing /home/user/.composer/cache/repo/https---composer.typo3.org/packages.json into cache
Reading /home/user/.composer/cache/repo/https---composer.typo3.org/include-all$696fe823dea214c8bc4ec4550c84cd3a4aae245b.json from cache
Executing command (CWD): git ls-remote --heads 'https://sub.domain.com/git/xyz'
Executing command (CWD): p4 -p https://sub.domain.com/git/xyz info -s


  [InvalidArgumentException]
  No driver found to handle VCS repository https://sub.domain.com/git/xyz


Exception trace:
 () at phar:///usr/local/bin/composer/src/Composer/Repository/VcsRepository.php:125
 Composer\Repository\VcsRepository->initialize() at phar:///usr/local/bin/composer/src/Composer/Repository/ArrayRepository.php:185
 Composer\Repository\ArrayRepository->getPackages() at phar:///usr/local/bin/composer/src/Composer/DependencyResolver/Pool.php:104
 Composer\DependencyResolver\Pool->addRepository() at phar:///usr/local/bin/composer/src/Composer/Installer.php:365
 Composer\Installer->doInstall() at phar:///usr/local/bin/composer/src/Composer/Installer.php:216
 Composer\Installer->run() at phar:///usr/local/bin/composer/src/Composer/Command/UpdateCommand.php:174
 Composer\Command\UpdateCommand->execute() at phar:///usr/local/bin/composer/vendor/symfony/console/Command/Command.php:259
 Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:844
 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:192
 Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:231
 Composer\Console\Application->doRun() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:123
 Symfony\Component\Console\Application->run() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:104
 Composer\Console\Application->run() at phar:///usr/local/bin/composer/bin/composer:43
 require() at /usr/local/bin/composer:24

update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [--with-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [-i|--interactive] [--root-reqs] [--] [<packages>]...

但是当我在https://user:password@sub.domain.com/git/xyz中使用https://sub.domain.com/git/xyz代替composer.json时,一切都很好。可能是什么问题?

1 个答案:

答案 0 :(得分:0)

这里有两个问题:

  1. 有一个bug
  2. 网址没有.git后缀。
  3. 对于第二个问题存在一个很好的解释:

      

    [后缀.git]无法检测[..]网址,因此它将依赖于完整检测,这涉及运行git ls-remote --heads <url>。但是由于缺少凭据,这确实会失败,因此检测不会将其检测为git repo。

    要解决第二个问题,只需使用git代替vcs作为存储库类型。

    另见https://github.com/composer/composer/issues/5543