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

使用Helm --set设置数组参数报错:zsh: no matches found

解决Helm --set设置数组时zsh的"no matches found"错误

这个问题我之前也碰到过!根源不是Helm的配置问题,而是zsh的默认行为在搞鬼:zshell会把命令里的[]当作文件名通配符去匹配系统里的文件,当没有找到对应名称的文件时,就会抛出no matches found的错误。而你手动修改values.yaml时,是直接编辑文件内容,shell不会参与解析YAML里的语法,所以不会触发这个问题。

给你几个可行的解决办法:

  1. 给--set参数整体加单引号
    把整个--set后面的内容用单引号包裹,让zsh跳过对里面特殊字符的解析:

    helm template . --set 'envVars.withSecret[0].key=POSTGRES_URL,envVars.withSecret[0].secretName=postgres_name,envVars.withSecret[0].secretKey=postgres_pw'
    
  2. 转义方括号
    在每个方括号[和]前面加反斜杠\,告诉zsh这是普通字符,不是通配符:

    helm template . --set envVars.withSecret\[0\].key=POSTGRES_URL,envVars.withSecret\[0\].secretName=postgres_name,envVars.withSecret\[0\].secretKey=postgres_pw
    
  3. 临时用bash执行命令
    如果不想修改zsh的行为,可以直接用bash来执行这条Helm命令:

    bash -c "helm template . --set envVars.withSecret[0].key=POSTGRES_URL,envVars.withSecret[0].secretName=postgres_name,envVars.withSecret[0].secretKey=postgres_pw"
    

随便选一种都能解决这个问题,我个人更推荐第一种,写法最简洁直观~

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.08 18:32:28