lima-vm/lima · error
configuration is nil
Error message
configuration is nil
What it means
validateConfig for the HCS driver requires a non-nil instance config; if cfg (*limatype.LimaYAML) is nil it returns 'configuration is nil'. This guards Validate/Configure against dereferencing a config that was never loaded, so it signals a lifecycle/initialization bug rather than a user YAML mistake.
Source
Thrown at pkg/driver/hcs/hcs_driver_windows.go:115
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 *LimaHcsDriver) 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")
}
// TODO: revise this list for HCS
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)
}
if cfg.TPM != nil && *cfg.TPM {
return errors.New("field `tpm` is not supported on HCS driver")View on GitHub (pinned to dd909d0973)
Solutions
- Load the config before validating: cfg, err := limayaml.Load(yamlPath, filePath) and assign it to Instance.Config
- Ensure the instance directory contains a valid lima.yaml (recreate the instance if missing)
- Fix the calling code so Validate/Configure run only after config population
Example fix
// before
drv := &hcs.LimaHcsDriver{Instance: &limatype.Instance{Name: "x"}} // Config nil
_ = drv.Validate(ctx) // configuration is nil
// after
cfg, err := limayaml.Load(yamlBytes, "lima.yaml")
if err != nil { return err }
drv.Instance.Config = cfg
_ = drv.Validate(ctx) Defensive patterns
Strategy: validation
Validate before calling
func ensureConfig(inst *limatype.Instance) error {
if inst == nil || inst.Config == nil {
return errors.New("instance config not loaded; call limayaml.Load and assign Instance.Config first")
}
return nil
} Type guard
func hasConfig(inst *limatype.Instance) bool {
return inst != nil && inst.Config != nil
} Try / catch
if err := drv.Validate(ctx); err != nil {
if err.Error() == "configuration is nil" {
// lifecycle bug: config was never loaded; load it and retry validation
return loadAndValidate(ctx, inst)
}
return err
} Prevention
- Always load lima.yaml via limayaml.Load before constructing/validating a driver
- Call Validate/Configure only through the normal limactl create flow
- Check that the instance directory exists and contains lima.yaml before driver setup
- In embedded use, assert inst.Config != nil at construction time
When it happens
Trigger: validateConfig invoked from Validate, Configure, or an anonymous callback with l.Instance.Config unset — instance struct constructed without loading lima.yaml, or Configure called before the config was populated by the instance loader.
Common situations: Programmatic use of the driver package where LimaYAML was never loaded via limayaml.Load; instance directory missing lima.yaml so the loader left Config nil; calling Validate out of the normal limactl create flow.
Related errors
AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01).
Data as JSON: /api/errors/e370ef7421558c11.
Report an issue: GitHub.