lima-vm/lima · error
no template available
Error message
no template available
What it means
renderTemplate refuses to run when TemplateFileBasedManager.template is empty; RegisterToStartAtLogin surfaces it (wrapped as "failed to render the autostart entry..."). It is a programming/configuration error: an autostart manager was built without the OS-specific unit/plist template.
Source
Thrown at pkg/autostart/managers.go:117
if registered, err := t.IsRegistered(ctx, inst); err != nil {
return fmt.Errorf("failed to check if the autostart entry for instance %#q is registered: %w", inst.Name, err)
} else if !registered {
return nil
}
if t.enabler != nil {
if err := t.enabler(ctx, false, inst.Name); err != nil {
return fmt.Errorf("failed to disable the autostart entry for instance %#q: %w", inst.Name, err)
}
}
if err := os.Remove(t.filePath(inst.Name)); err != nil {
return fmt.Errorf("failed to remove the autostart entry for instance %#q: %w", inst.Name, err)
}
return nil
}
func (t *TemplateFileBasedManager) renderTemplate(instName, workDir string, getExecutable func() (string, error)) ([]byte, error) {
if t.template == "" {
return nil, errors.New("no template available")
}
selfExeAbs, err := getExecutable()
if err != nil {
return nil, err
}
data := map[string]string{
"Binary": selfExeAbs,
"Instance": instName,
"WorkDir": workDir,
}
maps.Copy(data, t.extraTemplateVars)
return textutil.ExecuteTemplate(t.template, data)
}
func (t *TemplateFileBasedManager) AutoStartedIdentifier() string {
if t.autoStartedIdentifier != nil {
return t.autoStartedIdentifier()
}View on GitHub (pinned to dd909d0973)
Solutions
- Use the provided OS-specific constructors (NewSystemd/NewLaunchd/NewWindowsStartup) which populate the template
- If building a custom manager, set template to a valid systemd unit file / launchd plist template containing {{.Binary}}, {{.Instance}}, {{.WorkDir}} placeholders
Example fix
// before
mgr := &autostart.TemplateFileBasedManager{enabler: enable}
// after
mgr := autostart.NewSystemd() // template, filePath, enabler all set Defensive patterns
Strategy: validation
Validate before calling
// ensure the manager was built through a constructor with a template
if mgr == nil || !hasTemplate(mgr) {
mgr = autostart.NewSystemd() // or NewLaunchd / NewWindowsStartup
}
Type guard
func hasTemplate(m autostart.AutoStartManager) bool {
tfbm, ok := m.(*autostart.TemplateFileBasedManager)
return ok && tfbm != nil
}
Try / catch
if err := mgr.RegisterToStartAtLogin(ctx, inst); err != nil {
if strings.Contains(err.Error(), "no template available") {
return errors.New("autostart manager misconfigured: use NewSystemd/NewLaunchd constructor")
}
return err
}
Prevention
- Never construct TemplateFileBasedManager by hand; use NewSystemd/NewLaunchd/NewWindowsStartup
- When adding a new platform manager, always set template alongside filePath and enabler
- Add a unit test that calls renderTemplate/RegisterToStartAtLogin for each manager
When it happens
Trigger: RegisterToStartAtLogin is called on a TemplateFileBasedManager whose template field was never set — i.e. a manager constructed manually with only some fields, or a custom manager missing its template string.
Common situations: Embedding/using the internal autostart package in a fork or custom build and forgetting to set the systemd unit / launchd plist / Windows startup template; constructing TemplateFileBasedManager directly in tests.
Understand the failure class
Background: "missing required config value" errors: why libraries refuse to start when a configuration key is empty, unset, or blank — this error's family across 48 libraries.
Related errors
- no RequestStart function available
- no RequestStop function available
- failed to register instance %#q to start at login: %w
- failed to unregister instance %#q from start at login: %w
- failed to check if the autostart entry for instance %#q is r
AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01).
Data as JSON: /api/errors/89299b1b33aa5399.
Report an issue: GitHub.