You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Composer升级Magento 2.4.3至2.4.6遇插件找不到错误求助

Magento 2升级时composer-root-update-plugin找不到的问题解决

问题详情

按照Magento 2官方升级指南执行composer require magento/composer-root-update-plugin ~2.0 --no-update后,运行composer update触发如下错误:

Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires magento/composer-root-update-plugin, it could not be found in any version, there may be a typo in the package name.

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
 - It's a private package and you forgot to add a custom repository to find it

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

当前环境

  • Composer版本:2.5.5
  • PHP版本:7.4.33
  • 系统:Ubuntu 20.04.6 LTS

项目composer.json关键片段

{
"name": "magento/magento2ce",
"description": "Magento 2 (Open Source)",
"type": "project",
"license": [
    "OSL-3.0",
    "AFL-3.0"
],
"config": {
    "preferred-install": "dist",
    "sort-packages": true,
    "allow-plugins": {
        "laminas/laminas-dependency-plugin": true,
        "dealerdirect/phpcodesniffer-composer-installer": true,
        "magento/magento-composer-installer": true
    }
},
"version": "2.4.3",
"require": {
    "php": "~7.3.0||~7.4.0",
    [...]
    "magento/composer": "1.6.0",
    "magento/composer-root-update-plugin": "~2.0",
    "magento/magento-composer-installer": ">=0.1.11",
    "magento/zendframework1": "~1.14.2",
    [...]
},
"require-dev": {
    [...]
    "magento/magento-coding-standard": "*",
    "magento/magento2-functional-testing-framework": "^3.0",
    [...]
}
}

解决步骤

1. 检查并添加Magento官方仓库

magento/composer-root-update-plugin托管在Magento官方私有仓库,需确保项目composer.json包含该仓库配置:
在composer.json中添加或确认repositories节点:

"repositories": [
    {
        "type": "composer",
        "url": "https://repo.magento.com/"
    }
]

同时需确保已将Magento Marketplace的认证信息添加到auth.json(项目根目录或~/.composer/auth.json),认证信息可从Magento后台获取。

2. 修正插件安装方式

该插件是升级工具,无需添加到项目的require节点,正确用法是全局安装或直接通过插件命令执行升级:

  • 全局安装插件:
    composer global require magento/composer-root-update-plugin ~2.0
    
  • 直接使用插件执行升级(无需提前添加到项目依赖):
    composer require-commerce magento/product-community-edition 目标版本 --no-update
    
    替换目标版本为你要升级到的版本(如2.4.6)。

3. 验证包名拼写

确认magento/composer-root-update-plugin拼写完全正确,无大小写或字符错误。

4. 清理Composer缓存

清理缓存后重新尝试更新:

composer clear-cache
composer update

内容的提问来源于stack exchange,提问作者Gabbodrummer

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.22 18:47:05