lima-vm/lima · error

configuration is nil

Error message

configuration is nil

What it means

Error returned by the WSL2 driver's validateConfig (pkg/driver/wsl2/wsl_driver_windows.go:99) when the driver's Validate is called with a nil instance configuration (*limatype.LimaYAML). This indicates an internal inconsistency (e.g. the instance record has no loaded config) rather than a user YAML problem, since a nil config normally fails earlier during template load. Fix by ensuring the instance was created from a valid lima.yaml and that the config was properly attached to the driver before validation.

Source

Thrown at pkg/driver/wsl2/wsl_driver_windows.go:99

	if err := validateConfig(ctx, cfg); err != nil {
		return nil, err
	}

	l.Instance = inst
	l.SSHLocalPort = inst.SSHLocalPort

	return &driver.ConfiguredDriver{
		Driver: l,
	}, nil
}

func (l *LimaWslDriver) Validate(ctx context.Context) error {
	return validateConfig(ctx, l.Instance.Config)
}

func validateConfig(_ context.Context, cfg *limatype.LimaYAML) error {
	if cfg == nil {
		return errors.New("configuration is nil")
	}
	if cfg.MountType != nil && *cfg.MountType != limatype.WSLMount {
		return fmt.Errorf("field `mountType` must be %#q for WSL2 driver, got %#q", limatype.WSLMount, *cfg.MountType)
	}
	// TODO: revise this list for WSL2
	if cfg.VMType != nil {
		if unknown := reflectutil.UnknownNonEmptyFields(cfg, knownYamlProperties...); len(unknown) > 0 {
			logrus.Warnf("Ignoring: vmType %s: %+v", *cfg.VMType, unknown)
		}
	}

	if cfg.OS != nil && *cfg.OS == limatype.WINDOWS {
		return errors.New("currently Windows guest OS is only supported on QEMU")
	}

	if !limatype.IsNativeArch(*cfg.Arch) {
		return fmt.Errorf("unsupported arch: %#q", *cfg.Arch)
	}

View on GitHub (pinned to dd909d0973)

Solutions

  1. Recreate the instance (delete and re-create) to rebuild its config
  2. Update Lima to a version where the nil check is fixed
  3. Report as a bug with the steps that led to it

Example fix

// before
driver.Validate(ctx) // cfg nil -> "configuration is nil"
// after
cfg, err := limayaml.Load(instConfigPath, "default")
if err != nil { return err }
inst.Config = cfg
driver.Configure(cfg)
driver.Validate(ctx)
Defensive patterns

Strategy: type-guard

Validate before calling

const fs = require('fs');
const cfgPath = path.join(limaHome, 'instances', inst, 'lima.yaml');
if (!fs.existsSync(cfgPath)) throw new Error('Instance config missing at ' + cfgPath);

Type guard

function hasConfig(inst) { return inst != null && inst.config != null && typeof inst.config === 'object'; }

Try / catch

if (!hasConfig(driver.Instance)) {
  throw new Error('Driver not configured: call Configure(cfg) with a loaded LimaYAML first');
}
try { await driver.Validate(ctx); } catch (e) {
  if (e.message === 'configuration is nil') { /* reconfigure and retry */ }
  else throw e;
}

Prevention

When it happens

Trigger: LimaWslDriver.Validate, Configure, or an internal caller passes l.Instance.Config == nil — e.g. an instance record created without a loaded config or a corrupted instance directory missing lima.yaml.

Common situations: Instance directory missing/corrupted (lima.yaml deleted); programmatic use of the driver API without calling Configure; loading an instance from a partial/failed `limactl create`.

Related errors


AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01). Data as JSON: /api/errors/9fa07145dc0563a4. Report an issue: GitHub.