abiosoft/colima · error

could not load config from file

Error message

could not load config from file: %w

What it means

Returned by configmanager.LoadFrom when os.ReadFile fails while reading the YAML config file. The underlying filesystem error is wrapped with %w, so it is typically 'no such file or directory' or 'permission denied'. It fires before any YAML parsing, meaning the file itself could not be read from disk.

Solutions

  1. Run 'colima start' (or 'colima start --edit') once so the default config file is generated
  2. Verify the path exists and is readable: ls -l on the expected colima.yaml under the active config directory
  3. Fix ownership or permissions if present but unreadable: chown $USER file && chmod 644 file
  4. If the file was deleted intentionally, restore from backup or let colima regenerate defaults

Example fix

# before: config file was deleted
colima start    # error: could not load config from file

# after
colima start --edit   # regenerates the config template; save to create the file
Defensive patterns

Strategy: try-catch

Validate before calling

if _, err := os.Stat(cfgFile); err != nil {
    if errors.Is(err, fs.ErrNotExist) {
        // generate config first, e.g. run 'colima start' once
    }
    return err // permissions or other stat failure, fix before LoadFrom
}
c, err := configmanager.LoadFrom(cfgFile)

Try / catch

c, err := configmanager.LoadFrom(file)
if err != nil {
    var pathErr *os.PathError
    if errors.As(err, &pathErr) && errors.Is(pathErr.Err, fs.ErrNotExist) {
        // regenerate the config or fall back to defaults
    }
    // unreadable file: surface the wrapped %w cause to the user
    return err
}

Prevention

When it happens

Trigger: Calling configmanager.LoadFrom(file) with a path that does not exist (first run before colima.yaml is generated), a COLIMA_HOME/XDG_CONFIG_HOME location that never received a config, or a file with restrictive permissions or root ownership.

Common situations: Fresh machine where 'colima start' has never run; COLIMA_HOME pointing at a custom directory with no colima.yaml; config deleted or moved during cleanup; file created by sudo so the current user cannot read it.

Related errors


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

Appendix: source

Thrown at config/configmanager/configmanager.go:39

func SaveFromFile(file string) error {
	c, err := LoadFrom(file)
	if err != nil {
		return err
	}
	return Save(c)
}

// SaveToFile saves configuration to file.
func SaveToFile(c config.Config, file string) error {
	return yamlutil.Save(c, file)
}

// LoadFrom loads config from file.
func LoadFrom(file string) (config.Config, error) {
	var c config.Config
	b, err := os.ReadFile(file)
	if err != nil {
		return c, fmt.Errorf("could not load config from file: %w", err)
	}

	err = yaml.Unmarshal(b, &c)
	if err != nil {
		return c, fmt.Errorf("could not load config from file: %w", err)
	}

	return c, nil
}

// ValidateConfig validates config before we use it
func ValidateConfig(c config.Config) error {
	validMountTypes := map[string]bool{"9p": true, "sshfs": true}
	validPortForwarders := map[string]bool{"grpc": true, "ssh": true, "none": true}

	if util.MacOS13OrNewer() {
		validMountTypes["virtiofs"] = true
	}

View on GitHub (pinned to c3a5f9184d)