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

执行composer require drush/drush提示找不到drush/drush包如何解决

问题成因
  • 缺失Packagist官方包源:Composer默认从Packagist拉取公共包,当composer.json自定义repositories节点后会自动禁用默认的Packagist源。你当前配置的源仅包含Drupal官方包源和gigya模块的git源,而drush/drush托管在Packagist上,因此无法检索到包。
  • 版本兼容不匹配:你预期安装的Drush 10.6.1最低要求PHP版本为7.3,你当前使用的PHP 7.1.33无法满足依赖要求,就算能检索到包也会安装失败。
  • 源配置冗余:repositories节点中重复添加了两次Drupal 8包源,可能引发源数据同步冲突,进一步加剧检索异常。
解决步骤
  • 调整repositories配置:删除重复的Drupal源,同时添加Packagist官方源,修改后的repositories节点如下:
"repositories": {
    "packagist.org": {
        "type": "composer",
        "url": "https://packagist.org"
    },
    "drupal": {
        "type": "composer",
        "url": "https://packages.drupal.org/8"
    },
    "gigyadrupal": {
        "type": "git",
        "url": "https://github.com/gigya/drupal8.git"
    }
}
  • 清理Composer缓存,避免旧的源数据干扰,执行命令:
    composer clear-cache
  • 安装适配你环境的Drush版本:PHP 7.1最高支持Drush 9.x分支,执行以下命令即可完成安装:
    composer require drush/drush:^9.7

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.01 03:27:00