Composer给我[ErrorException]未定义的索引:安装后的用户名



我在Ubuntu上,我已经按照composer网站指南安装了composer:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '756890a4488ce9024fc62c56153228907f1545c228516cbf63f885e036d37e9a59d27d63f46af1d4d07ee0f76181c7d3') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

然后我按照以下说明操作:

最有可能的情况是,您希望将composer.phar放入PATH上的一个目录中,因此您可以简单地从任何目录调用composer(全局安装(,例如:

sudo mv composer.phar /usr/local/bin/composer

现在,当我调用composer -v时,我得到了这个错误:

composer -v

[ErrorException]           
Undefined index: username  

Exception trace:
() at phar:///usr/local/bin/composer/src/Composer/IO/BaseIO.php:147
ComposerUtilErrorHandler::handle() at phar:///usr/local/bin/composer/src/Composer/IO/BaseIO.php:147
ComposerIOBaseIO->loadConfiguration() at phar:///usr/local/bin/composer/src/Composer/Factory.php:346
ComposerFactory->createComposer() at phar:///usr/local/bin/composer/src/Composer/Factory.php:604
ComposerFactory::create() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:416
ComposerConsoleApplication->getComposer() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:535
ComposerConsoleApplication->getPluginCommands() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:189
ComposerConsoleApplication->doRun() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:117
SymfonyComponentConsoleApplication->run() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:125
ComposerConsoleApplication->run() at phar:///usr/local/bin/composer/bin/composer:64
require() at /usr/local/bin/composer:24

以下是composer.json 项目

{
"name": "magento/project-community-edition",
"description": "eCommerce Platform for Growth (Community Edition)",
"type": "project",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"config": {
"preferred-install": "dist",
"sort-packages": true
},
"version": "2.4.1",
"require": {
"magento/composer-root-update-plugin": "~1.0",
"magento/product-community-edition": "2.4.1",
"scandipwa/sample-data": "^1.1",
"scandipwa/theme": "^0.0.1"
},
"autoload": {
"exclude-from-classmap": [
"**/dev/**",
"**/update/**",
"**/Test/**"
],
"files": [
"app/etc/NonComposerComponentRegistration.php"
],
"psr-0": {
"": [
"app/code/",
"generated/code/"
]
},
"psr-4": {
"Magento\": "app/code/Magento/",
"Magento\Framework\": "lib/internal/Magento/Framework/",
"Magento\Setup\": "setup/src/Magento/Setup/",
"Zend\Mvc\Controller\": "setup/src/Zend/Mvc/Controller/"
}
},
"require-dev": {
"allure-framework/allure-phpunit": "~1.2.0",
"dealerdirect/phpcodesniffer-composer-installer": "^0.5.0",
"friendsofphp/php-cs-fixer": "~2.16.0",
"lusitanian/oauth": "~0.8.10",
"magento/magento-coding-standard": "*",
"magento/magento2-functional-testing-framework": "^3.0",
"pdepend/pdepend": "~2.7.1",
"phpcompatibility/php-compatibility": "^9.3",
"phpmd/phpmd": "^2.8.0",
"phpstan/phpstan": ">=0.12.3 <=0.12.23",
"phpunit/phpunit": "^9",
"sebastian/phpcpd": "~5.0.0",
"squizlabs/php_codesniffer": "~3.5.4"
},
"conflict": {
"gene/bluefoot": "*"
},
"autoload-dev": {
"psr-4": {
"Magento\PhpStan\": "dev/tests/static/framework/Magento/PhpStan/",
"Magento\Sniffs\": "dev/tests/static/framework/Magento/Sniffs/",
"Magento\TestFramework\Inspection\": "dev/tests/static/framework/Magento/TestFramework/Inspection/",
"Magento\TestFramework\Utility\": "dev/tests/static/framework/Magento/TestFramework/Utility/",
"Magento\Tools\": "dev/tools/Magento/Tools/",
"Magento\Tools\Sanity\": "dev/build/publication/sanity/Magento/Tools/Sanity/"
}
},
"minimum-stability": "stable",
"prefer-stable": true,
"repositories": {
"0": {
"type": "composer",
"url": "https://repo.magento.com/"
},
"scandipwa": {
"type": "path",
"url": "scandipwa"
}
},
"extra": {
"magento-force": "override"
}
}

在我的情况下,这是因为COMPOSER_HOME中的auth.json

{
"http-basic": {
"http-basic": {
"php.fury.io": {
"username": "",
"password": ""
}
},
}
}
// should be
{
"http-basic": {
"php.fury.io": {
"username": "",
"password": ""
}
}
}

这似乎就像一位作曲家试图寻找的"用户名";在";http基本";但它找不到它,并导致未定义的";用户名";索引错误。

相关内容

  • 没有找到相关文章

最新更新