abiosoft/colima · error
error marshalling settings to json: %w
Error message
error marshalling settings to json: %w
What it means
Returned by limaVM.Set when json.Marshal of the in-memory settings map (map[string]interface{} loaded from the VM-side config file) fails before persisting. Like the other marshal guards in this package it is defensive: a map decoded from JSON re-encodes cleanly unless it contains non-serializable injected values.
Source
Thrown at environment/vm/lima/config.go:42
_ = json.Unmarshal([]byte(b), &obj)
return obj
}
func (l limaVM) Get(key string) string {
if val, ok := l.getConf()[key]; ok {
return val
}
return ""
}
func (l limaVM) Set(key, value string) error {
obj := l.getConf()
obj[key] = value
b, err := json.Marshal(obj)
if err != nil {
return fmt.Errorf("error marshalling settings to json: %w", err)
}
if err := l.Run("sudo", "mkdir", "-p", filepath.Dir(configFile)); err != nil {
return fmt.Errorf("error saving settings: %w", err)
}
if err := l.Write(configFile, b); err != nil {
return fmt.Errorf("error saving settings: %w", err)
}
return nil
}
View on GitHub (pinned to c3a5f9184d)
Solutions
- If you maintain a fork, keep the settings map limited to JSON-native types (string, bool, float64, map, slice).
- Reset persisted VM settings to reseed a clean map: delete the profile ('colima delete -f') and start again.
- Upgrade colima if you hit this on a released binary and file an issue with the stack trace — it indicates an internal bug.
Defensive patterns
Strategy: validation
Validate before calling
// keep the settings map JSON-native before marshalling
for k, v := range obj {
if !isJSONNative(v) { // string, bool, float64, map[string]interface{}, []interface{}, nil
return fmt.Errorf("settings key %q holds non-serializable value %T", k, v)
}
} Type guard
func isJSONNative(v interface{}) bool {
switch v.(type) {
case nil, string, bool, float64, json.Number,
map[string]interface{}, []interface{}:
return true
}
return false
} Try / catch
b, err := json.Marshal(obj)
if err != nil {
// defensive path: drop to a fresh map rather than failing the VM start
log.Warnln(fmt.Errorf("error marshalling settings to json: %w", err))
b, _ = json.Marshal(map[string]string{key: value})
} Prevention
- In forks, never insert chan/func/complex values into limaVM settings.
- Round-trip test Set/GetConf in unit tests.
- Treat this error as an internal bug signal on stock builds.
When it happens
Trigger: Only if getConf() loaded/produced a map containing a json-incompatible value (chan/func/complex or a failing custom marshaler) — not producible from the JSON file itself; a corrupt or fork-modified codepath is the realistic source. Call sites are settings persistence (e.g. kubernetes runtime setConfig writing ConfigKey) during 'colima start'.
Common situations: Essentially never on stock builds; appears in forks that stuff arbitrary Go values into the settings map, or after tampering with the embedded config plumbing.
Related errors
- error encoding kubernetes config to json: %w
- error marshaling store: %w
- error decoding 'limactl info' json: %w
- error saving settings: %w
- dependency check failed for VM: %w
AI-assisted analysis of abiosoft/colima@c3a5f9184d (2026-08-15).
Data as JSON: /api/errors/0efb3ef98b874f7f.
Report an issue: GitHub.