{"record":{"id":"b9b0abacf7cd29fe","repo":"lima-vm/lima","slug":"failed-to-create-user-q-w","errorCode":null,"errorMessage":"failed to create user %#q: %w","messagePattern":"failed to create user %#q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/guestagent/fakecloudinit/fakecloudinit_darwin.go","lineNumber":121,"sourceCode":"\tif userData.PackageUpgrade {\n\t\tlogrus.Warn(\"package_upgrade is not implemented\")\n\t}\n\tif userData.PackageRebootIfRequired {\n\t\tlogrus.Warn(\"package_reboot_if_required is not implemented\")\n\t}\n\tfor _, m := range userData.Mounts {\n\t\tif err = mountFSTabEntry(m); err != nil {\n\t\t\terrs = append(errs, fmt.Errorf(\"failed to mount fstab entry %v: %w\", m, err))\n\t\t}\n\t}\n\tif userData.Timezone != \"\" {\n\t\tif err = setTimezone(ctx, userData.Timezone); err != nil {\n\t\t\terrs = append(errs, fmt.Errorf(\"failed to set timezone: %w\", err))\n\t\t}\n\t}\n\tfor _, u := range userData.Users {\n\t\tif err := createUser(ctx, &u); err != nil {\n\t\t\terrs = append(errs, fmt.Errorf(\"failed to create user %#q: %w\", u.Name, err))\n\t\t}\n\t}\n\tfor _, entry := range userData.WriteFiles {\n\t\tif err := writeFiles(ctx, entry); err != nil {\n\t\t\terrs = append(errs, fmt.Errorf(\"failed to write file for path %#q: %w\", entry.Path, err))\n\t\t}\n\t}\n\tif userData.ManageResolvConf && userData.ResolvConf != nil {\n\t\tif err = setResolvConf(ctx, userData.ResolvConf); err != nil {\n\t\t\terrs = append(errs, fmt.Errorf(\"failed to apply DNS configuration: %w\", err))\n\t\t}\n\t}\n\tif userData.CACerts != nil {\n\t\tlogrus.Warn(\"ca_certs is not implemented\")\n\t}\n\tif len(userData.BootCmd) > 0 {\n\t\tlogrus.Warn(\"bootcmd is not implemented\")\n\t}","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/guestagent/fakecloudinit/fakecloudinit_darwin.go#L103-L139","documentation":"Raised by processUserData when creating one of the users listed in the user-data `users:` array fails on macOS. createUser performs several steps (sysadminctl -addUser, home directory population, SSH keys, sudoers), and the wrapped error identifies the failing step. The username is included via %#q.","triggerScenarios":"A `users:` entry lacks `homedir` or `uid` (both required by this implementation), the uid is not numeric, sysadminctl fails to add the user, or populating the home directory / writing password, .ssh, or sudoers files fails.","commonSituations":"Using the stock Linux cloud-init `default` user entry (no homedir/uid), picking a UID already in use by macOS (Setup Assistant users), or an invalid sudo config string containing newlines.","solutions":["Read the wrapped error: it names the failing step (homedir required, uid required, invalid uid, sysadminctl, home dir, sudoers, etc.).","Add `homedir` and a numeric `uid` to each users entry; both are mandatory in this fake cloud-init.","Choose a UID that does not collide with existing macOS users.","Ensure the sudo string is a single line without newline characters.","If the user already exists (homedir present), creation is skipped automatically - verify the homedir path is not stale."],"exampleFix":"// before (user-data)\nusers:\n  - name: alice\n// after\nusers:\n  - name: alice\n    homedir: /Users/alice\n    uid: \"501\"","handlingStrategy":"validation","validationCode":"func validateUsers(users []cloudinittypes.User) error {\n  for i, u := range users {\n    if u.Homedir == \"\" { return fmt.Errorf(\"users[%d] %q: homedir required\", i, u.Name) }\n    if _, err := strconv.Atoi(u.UID); err != nil { return fmt.Errorf(\"users[%d] %q: uid must be numeric\", i, u.Name) }\n    if strings.Contains(u.Sudo, \"\\n\") { return fmt.Errorf(\"users[%d] %q: sudo must be single line\", i, u.Name) }\n  }\n  return nil\n}","typeGuard":"func isProvisionableUser(u *cloudinittypes.User) bool {\n  return u.Name != \"\" && u.Homedir != \"\" && u.UID != \"\"\n}","tryCatchPattern":"for _, u := range userData.Users {\n  if err := createUser(ctx, &u); err != nil {\n    log.Errorf(\"user %q skipped: %v\", u.Name, err) // continue with remaining users\n  }\n}","preventionTips":["Always set homedir and numeric uid for every users entry on macOS.","Avoid UID collisions with existing macOS accounts (check existing users first).","Keep the sudo string on one line.","Remember the agent skips creation if the homedir already exists - reuse that for idempotency."],"tags":["macos","cloud-init","user-creation","sysadminctl"],"backgroundTag":"user-provisioning-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}