helm/helm · error

cannot load Chart.yaml: %w

Error message

cannot load Chart.yaml: %w

What it means

Thrown by LoadDir when Chart.yaml exists but cannot be unmarshalled: sigs.k8s.io/yaml (YAML→JSON→struct) rejects its content. Typical causes are YAML syntax errors (tabs for indentation, bad colons, unclosed quotes) or duplicate keys, but it also fires on structurally wrong content such as a YAML list at the top level. The wrapped error pinpoints the parse location.

Source

Thrown at pkg/chart/loader/load.go:92

	return LoadDir(string(l))
}

func LoadDir(dir string) (chart.Charter, error) {
	topdir, err := filepath.Abs(dir)
	if err != nil {
		return nil, err
	}

	name := filepath.Join(topdir, "Chart.yaml")
	data, err := os.ReadFile(name)
	if err != nil {
		return nil, fmt.Errorf("unable to detect chart at %s: %w", name, err)
	}

	c := new(chartBase)
	err = yaml.Unmarshal(data, c)
	if err != nil {
		return nil, fmt.Errorf("cannot load Chart.yaml: %w", err)
	}

	switch c.APIVersion {
	case c2.APIVersionV1, c2.APIVersionV2, "":
		return c2load.Load(dir)
	case c3.APIVersionV3:
		return c3load.Load(dir)
	default:
		return nil, errors.New("unsupported chart version")
	}
}

// FileLoader loads a chart from a file
type FileLoader string

// Load loads a chart
func (l FileLoader) Load() (chart.Charter, error) {
	return LoadFile(string(l))

View on GitHub (pinned to 2a29f1770b)

Solutions

  1. Run the wrapped error's line/column down and fix the YAML: check for tabs, duplicate keys, unquoted special characters
  2. Validate syntax: yamllint Chart.yaml or helm lint ./chart
  3. If a merge conflict left markers (<<<<<<<), resolve it fully and remove them
  4. Quote strings containing colons or # (e.g. description: 'Key: value')

Example fix

# before: Chart.yaml with a tab and duplicate key
name:	mychart
version: 0.1.0
name: other

# after: clean Chart.yaml
name: mychart
version: 0.1.0
Defensive patterns

Strategy: validation

Validate before calling

// Parse Chart.yaml up front for a precise error before chart operations
func chartYamlValid(dir string) error {
    data, err := os.ReadFile(filepath.Join(dir, "Chart.yaml"))
    if err != nil { return err }
    var m map[string]any
    if err := sigsyaml.Unmarshal(data, &m); err != nil {
        return fmt.Errorf("Chart.yaml invalid: %w", err)
    }
    return nil
}

Try / catch

chrt, err := loader.Load(dir)
if err != nil {
    if strings.Contains(err.Error(), "cannot load Chart.yaml") {
        // the wrapped error carries line/column; fix tabs, duplicate keys, quoting
    }
}

Prevention

When it happens

Trigger: loader.Load/LoadDir on a chart whose Chart.yaml contains tab characters, duplicated keys (e.g. 'name:' twice), an unterminated string, or content that is not a mapping; also Chart.yaml with invalid types for known fields. Detected during the apiVersion sniffing step before the v2/v3 loader runs.

Common situations: Hand-editing Chart.yaml with editors inserting tabs; merge conflicts resolved badly leaving conflict markers; copy-paste from rendered docs mangling indentation; linters absent in the chart workflow.

Related errors


AI-assisted analysis of helm/helm@2a29f1770b (2026-08-15). Data as JSON: /api/errors/11d2406784eaadef. Report an issue: GitHub.