解决 Helm 报错 index.yaml is corrupted 仓库索引解析失败
分析 Helm 执行 repo update 报 index.yaml is corrupted 根因,详解本地缓存索引清理与远程仓库索引重新生成方案。
问题现象
执行 helm repo update 或搜索 Chart 时报错失败:
Error: Failed to parse index.yaml, file is corrupted: error converting YAML to JSON: yaml: line 120: mapping values are not allowed in this context
触发根因
- 本地下载的缓存
index.yaml文件内容截断或被代理篡改(如返回了 HTML 错误页)。
诊断排查步骤
- 检查本地缓存索引文件内容:
cat ~/.cache/helm/repository/my-repo-index.yaml | head -n 20
观察是否混入了 HTML 或语法截断。
解决步骤与操作命令
步骤一:清空 Helm 本地所有仓库缓存
rm -rf ~/.cache/helm/repository/*
步骤二:重新更新仓库索引
helm repo update
步骤三:若远程仓库自身生成的 index.yaml 损坏,使用 helm repo index 重新生成
helm repo index /path/to/charts --url https://my-charts.internal/
验证方法
再次执行仓库更新与搜索:
helm search repo my-app
成功列出各可用版本,无任何解析错误。


