ESP-IDF 安装卡在 submodule foreach git config core.fileMode 错误解决
今天安装 esp-idf-tools-setup-offline-5.4.2.exe 的时候,卡在'完成 esp-idf 安装,在子模块中更新'阶段。
报错信息
Running command: D:\soft\esp_idf\ins\Espressif\tools\idf-git\2.44.0\cmd\git.exe -C D:\soft\esp_idf\ins\Espressif\frameworks\esp-idf-v5.4.2 submodule foreach --recursive git config --local core.fileMode false
问题原因
Espressif 自带的 idf-git(实际上是一个封装的 Git + MSYS2 工具包)在 Windows10 上调用 sed 出错,导致卡在 submodule foreach。解决思路是用系统里安装的 Git 替换掉 ESP-IDF 自带的 idf-git。
解决方案:永久替换 idf-git
步骤 1:确认 ESP-IDF 使用的 git 路径
打开命令行(Win + R → 输入 cmd → 回车),输入以下命令查看当前系统 Git 路径:
where git
确保结果为:
C:\Program Files\Git\cmd\git.exe
步骤 2:备份原始 idf-git
找到 ESP-IDF 目录下的 git.exe,右键重命名为 git_old.exe 以便恢复。
路径示例:
D:\soft\esp_idf\ins\Espressif\tools\idf-git\2.44.0\cmd\
步骤 3:用符号链接替换
- 以管理员身份打开命令行。
- 执行以下命令创建符号链接(注意路径需带双引号):
mklink "D:\soft\esp_idf\ins\Espressif\tools\idf-git\2.44.0\cmd\git.exe" "C:\Program Files\Git\cmd\git.exe"
如果成功,会显示'符号链接已创建'。这一步让 ESP-IDF 目录下的 git.exe 实际上指向系统 Git。
步骤 4:验证是否替换成功
在 CMD 中执行:
"D:\soft\esp_idf\ins\Espressif\tools\idf-git\2.44.0\cmd\git.exe" --version
如果显示系统 Git 的版本(如 2.50.1.windows.1),说明替换成功。
步骤 5:重新运行 ESP-IDF 安装器
现在再运行 install.bat,它会继续使用 idf-git 路径,但实际上调用的是系统 Git,不会再触发 sed: read error on stdin: Bad file descriptor 错误。


