lima-vm/lima · error
failed to set timezone: %w
Error message
failed to set timezone: %w
What it means
Raised by processUserData when the `timezone:` field is set in user-data but the macOS `systemsetup -settimezone` command fails. The command's combined output is wrapped into the underlying error by setTimezone, so the message reveals why the timezone could not be applied.
Source
Thrown at pkg/guestagent/fakecloudinit/fakecloudinit_darwin.go:116
logrus.Warn("growpart is not implemented")
}
if userData.PackageUpdate {
logrus.Warn("package_update is not implemented")
}
if userData.PackageUpgrade {
logrus.Warn("package_upgrade is not implemented")
}
if userData.PackageRebootIfRequired {
logrus.Warn("package_reboot_if_required is not implemented")
}
for _, m := range userData.Mounts {
if err = mountFSTabEntry(m); err != nil {
errs = append(errs, fmt.Errorf("failed to mount fstab entry %v: %w", m, err))
}
}
if userData.Timezone != "" {
if err = setTimezone(ctx, userData.Timezone); err != nil {
errs = append(errs, fmt.Errorf("failed to set timezone: %w", err))
}
}
for _, u := range userData.Users {
if err := createUser(ctx, &u); err != nil {
errs = append(errs, fmt.Errorf("failed to create user %#q: %w", u.Name, err))
}
}
for _, entry := range userData.WriteFiles {
if err := writeFiles(ctx, entry); err != nil {
errs = append(errs, fmt.Errorf("failed to write file for path %#q: %w", entry.Path, err))
}
}
if userData.ManageResolvConf && userData.ResolvConf != nil {
if err = setResolvConf(ctx, userData.ResolvConf); err != nil {
errs = append(errs, fmt.Errorf("failed to apply DNS configuration: %w", err))
}
}
if userData.CACerts != nil {View on GitHub (pinned to dd909d0973)
Solutions
- Read the wrapped output in the error message to see systemsetup's actual complaint.
- Use a valid IANA timezone identifier (check `systemsetup -listtimezones` in the VM).
- Ensure the guestagent runs as root, since systemsetup requires elevated privileges.
- If the timezone is not essential, remove the `timezone:` field from user-data; it is optional.
Example fix
// before (user-data) timezone: "America/Los_Angeless" // after timezone: "America/Los_Angeles"
Defensive patterns
Strategy: validation
Validate before calling
func validateTimezone(tz string) error {
if tz == "" { return nil }
valid := tzRegexp.MatchString(tz) // e.g. `^[A-Za-z]+(/[A-Za-z0-9_+-]+)+$`
if !valid { return fmt.Errorf("suspicious timezone %q", tz) }
return nil
} Type guard
func isIANATimezone(s string) bool {
loc, err := time.LoadLocation(s)
return err == nil && loc != nil
} Try / catch
if userData.Timezone != "" {
if err := setTimezone(ctx, userData.Timezone); err != nil {
log.Warnf("timezone %q not applied, continuing: %v", userData.Timezone, err)
}
} Prevention
- Validate the timezone with time.LoadLocation before shipping user-data.
- Run the guestagent as root; systemsetup requires privileges.
- Do not treat timezone failure as fatal - it is non-essential for boot.
- Check `systemsetup -listtimezones` inside the guest for the exact accepted names.
When it happens
Trigger: userData.Timezone is non-empty and exec of `systemsetup -settimezone <tz>` returns non-zero: invalid timezone identifier, missing/locked systemsetup, or insufficient privileges (systemsetup typically requires root on macOS).
Common situations: Typo in the timezone name (e.g. `Europe/Amsterdamn` instead of `Europe/Amsterdam`), running the guest agent as a non-root user, or a managed/MDM-locked macOS image where systemsetup is restricted.
Related errors
- failed to enable SSHD: %w
- failed to mount fstab entry %v: %w
- failed to create user %#q: %w
- failed to write file for path %#q: %w
- failed to apply DNS configuration: %w
AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01).
Data as JSON: /api/errors/3edcbc53a0523482.
Report an issue: GitHub.