abiosoft/colima · error

error marshalling Lima network config file: %w

Error message

error marshalling Lima network config file: %w

What it means

Error returned when yaml.Marshal fails to serialize defaultLimaNetworkConfig (the Lima user-v2 network template, including the gateway address) to YAML. For a plain struct of strings this is nearly unreachable; it would require a field value that the YAML encoder rejects.

Source

Thrown at environment/vm/lima/network.go:52

	gatewayAddress := conf.Network.GatewayAddress
	if gatewayAddress != nil {
		defaultLimaNetworkConfig.Networks.UserV2.Gateway = gatewayAddress
	}

	// if there are no running instances, clear network directory
	if instances, err := limautil.RunningInstances(); err == nil && len(instances) == 0 {
		if err := os.RemoveAll(limautil.NetworkAssetsDirectory()); err != nil {
			logrus.Warnln(fmt.Errorf("could not clear network assets directory: %w", err))
		}
	}

	if err := os.MkdirAll(filepath.Dir(networkFile), 0755); err != nil {
		return fmt.Errorf("error creating Lima config directory: %w", err)
	}

	networkFileMarshalled, err := yaml.Marshal(&defaultLimaNetworkConfig)
	if err != nil {
		return fmt.Errorf("error marshalling Lima network config file: %w", err)
	}

	if err := os.WriteFile(networkFile, networkFileMarshalled, 0755); err != nil {
		return fmt.Errorf("error writing Lima network config file: %w", err)
	}
	return nil
}

func (l *limaVM) replicateHostAddresses(conf config.Config) error {
	if !conf.Network.Address && conf.Network.HostAddresses {
		for _, ip := range util.HostIPAddresses() {
			if err := l.RunQuiet("sudo", "ip", "address", "add", ip.String()+"/24", "dev", "lo"); err != nil {
				return err
			}
		}
	}
	return nil
}

View on GitHub (pinned to c3a5f9184d)

Solutions

  1. Treat as a colima bug: upgrade to the latest release
  2. If reproducible, report with 'colima version' and the full startup log
  3. Workaround: start without network customization (no --network flags) if the issue involves custom network settings
Defensive patterns

Strategy: try-catch

Try / catch

Structural marshal failure: catch, log the full struct for the bug report, and retry once without custom network fields (defaults) so startup can proceed while the defect is reported upstream.

Prevention

When it happens

Trigger: Marshalling the network config struct with an unserializable field value — practically only via an internal type change or corrupted construction; there is no user-facing knob that feeds raw unserializable data into this struct.

Common situations: Almost never seen in the field; if reported, it correlates with a colima build bug or a patched fork where a network field type no longer marshals.

Related errors


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