abiosoft/colima · error

error reading config file: %w

Error message

error reading config file: %w

What it means

encodeYAML (util/yamlutil/yaml.go:44) reads the template document embedded/defaults/colima.yaml via embedded.Read; failure means the embedded filesystem in the running binary does not contain that asset. This is not a user-configuration problem — it indicates a broken or incomplete build (embed directive not applied, partial checkout, truncated/corrupted binary). The config-save path depends on it, so colima cannot persist settings until fixed.

Source

Thrown at util/yamlutil/yaml.go:44

// Save saves the config.
func Save(c config.Config, file string) error {
	b, err := encodeYAML(c)
	if err != nil {
		return err
	}
	if err := os.WriteFile(file, b, 0644); err != nil {
		return fmt.Errorf("error writing yaml file: %w", err)
	}

	return nil
}

func encodeYAML(conf config.Config) ([]byte, error) {
	var doc yaml.Node

	f, err := embedded.Read("defaults/colima.yaml")
	if err != nil {
		return nil, fmt.Errorf("error reading config file: %w", err)
	}

	if err := yaml.Unmarshal(f, &doc); err != nil {
		return nil, fmt.Errorf("embedded default config is invalid yaml: %w", err)
	}

	if l := len(doc.Content); l != 1 {
		return nil, fmt.Errorf("unexpected error during yaml decode: doc has multiple children of len %d", l)
	}
	root := doc.Content[0]

	// get all nodes
	nodeVals := map[string]*yaml.Node{}
	if err := traverseNode("", root, nodeVals); err != nil {
		return nil, fmt.Errorf("error traversing yaml node: %w", err)
	}

	// get all node values

View on GitHub (pinned to c3a5f9184d)

Solutions

  1. Reinstall the official build: `brew reinstall colima` (or re-download the release artifact)
  2. Rebuild from a clean, full checkout and confirm the embed directive covers embedded/defaults/colima.yaml
  3. Verify binary integrity (sha256 against the release manifest) to rule out truncation/corruption
  4. In forks, keep the embedded assets path stable or update embedded.Read accordingly

Example fix

# before (fork broke embed paths)
$ ./colima start
error reading config file: open defaults/colima.yaml: file does not exist

# after
$ brew reinstall colima
$ colima start
Defensive patterns

Strategy: fallback

Validate before calling

// for colima forks: verify embedded assets at process start
if _, err := embedded.Read("defaults/colima.yaml"); err != nil {
    log.Fatal("binary missing embedded defaults — rebuild from a full checkout")
}

Try / catch

if err := util.Save(cfg, file); err != nil {
    if strings.Contains(err.Error(), "error reading config file") {
        // binary-level defect: reinstall rather than retry
        return fmt.Errorf("colima install is broken (missing embedded defaults) — reinstall colima")
    }
    return err
}

Prevention

When it happens

Trigger: Running a colima binary built from a tree where the embedded dir was excluded (wrong build tags, stripped assets, `go build` from a partial archive); a truncated download of the release binary; antivirus/quarantine mangling the Mach-O with embedded FS.

Common situations: Custom forks with restructured directories that broke the embed.FS path; binaries copied between machines with corruption; building with tools that prune embedded files to shrink binaries.

Related errors


AI-assisted analysis of abiosoft/colima@c3a5f9184d (2026-08-15). Data as JSON: /api/errors/941fb6a307b35a08. Report an issue: GitHub.