abiosoft/colima · critical
error parsing disk mount script template: %v
Error message
error parsing disk mount script template: %v
What it means
diskMountScript (environment/vm/lima/disk.go:107) parses the hardcoded diskScript template with a fixed values struct {Format bool, InstanceId string}; if ParseTemplate returns any error it panics with this message ('must never happen'). Because both the template body and the values are compile-time constants in the same file, the only way to reach the panic is a source edit that breaks the template (syntax error) or references a field absent from the values struct. It crashes the CLI at VM startup whenever a runtime disk is provisioned.
Source
Thrown at environment/vm/lima/disk.go:107
return incus.DataDisk()
}
return environment.DataDisk{}
}
func diskMountScript(format bool) string {
var values = struct {
Format bool
InstanceId string
}{
Format: format,
InstanceId: config.CurrentProfile().ID,
}
b, err := util.ParseTemplate(diskScript, values)
if err != nil {
// must never happen
panic(fmt.Sprintf("error parsing disk mount script template: %v", err))
}
return string(b)
}
func (l *limaVM) mountRuntimeDisk(conf config.Config, format bool) {
// provision script to prepare disk
l.limaConf.Provision = append(l.limaConf.Provision, limaconfig.Provision{
Mode: "dependency",
Script: diskMountScript(format),
})
// handle disk mounts
disk := dataDisk(conf.Runtime)
// pre mount script
for _, script := range disk.PreMount {
l.limaConf.Provision = append(l.limaConf.Provision, limaconfig.Provision{
Mode: "dependency",View on GitHub (pinned to c3a5f9184d)
Solutions
- Fix the template literal in disk.go: match field names exactly (Format, InstanceId) and balance delimiters
- Add a unit test that calls diskMountScript(true) and diskMountScript(false) and asserts no panic and non-empty output
- Run `go test ./environment/...` after touching templates before starting a VM
- If hit on a stock binary, reinstall — it means the binary does not match the sources
Example fix
// environment/vm/lima/disk.go (before)
const diskScript = `echo {{.format}} {{.InstanceId}}` // .format -> execute error -> panic
// after
const diskScript = `echo {{.Format}} {{.InstanceId}}` Defensive patterns
Strategy: try-catch
Validate before calling
// fork safety net: validate the disk template at init/test time
func init() {
if _, err := util.ParseTemplate(diskScript, struct {
Format bool
InstanceId string
}{true, "test"}); err != nil {
panic("diskScript template is broken: " + err.Error())
}
} Try / catch
// if you call code that may panic during template generation:
defer func() {
if r := recover(); r != nil {
return fmt.Errorf("disk mount script generation failed: %v", r)
}
}() Prevention
- Unit-test diskMountScript(true) and diskMountScript(false) after any template edit
- Keep template field names in lockstep with the values struct
- Run `go test ./environment/vm/lima/...` before starting a VM in dev builds
- Never ship a dev-built binary without the template tests passing
When it happens
Trigger: Editing the diskScript template literal in environment/vm/lima/disk.go and introducing a typo ({{.format}} instead of {{.Format}}, missing braces), then running `colima start` with a disk configured — the panic fires while generating the Lima provision script.
Common situations: Fork development around disk mounting; renaming config fields without updating the template; build from a dirty tree mid-refactor.
Related errors
- error deleting container data: %w
- error creating runtime disk: %w
- dependency check failed for VM: %w
- error starting vm: %w
- error stopping vm: %w
AI-assisted analysis of abiosoft/colima@c3a5f9184d (2026-08-15).
Data as JSON: /api/errors/4429266797963913.
Report an issue: GitHub.