{"record":{"id":"4785eaace0896f31","repo":"lima-vm/lima","slug":"failed-to-run-v-w","errorCode":null,"errorMessage":"failed to run %v: %w","messagePattern":"failed to run (.+?): %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/networks/sudoers.go","lineNumber":64,"sourceCode":"\t\t\tuser, err := cfg.User(daemon)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\t\t\tsb.WriteRune('\\n')\n\t\t\tfmt.Fprintf(&sb, \"%%%s ALL=(%s:%s) NOPASSWD:NOSETENV: \\\\\\n\", cfg.Group, user.User, user.Group)\n\t\t\tfmt.Fprintf(&sb, \"    %s, \\\\\\n\", cfg.StartCmd(name, daemon))\n\t\t\tfmt.Fprintf(&sb, \"    %s\\n\", cfg.StopCmd(name, daemon))\n\t\t}\n\t}\n\treturn sb.String(), nil\n}\n\nfunc (c *Config) passwordLessSudo(ctx context.Context) error {\n\t// Flush cached sudo password\n\tcmd := exec.CommandContext(ctx, \"sudo\", \"-k\")\n\tlogrus.Infof(\"Running: %v\", cmd.Args)\n\tif err := cmd.Run(); err != nil {\n\t\treturn fmt.Errorf(\"failed to run %v: %w\", cmd.Args, err)\n\t}\n\t// Verify that user/groups for both daemons work without a password, e.g.\n\t// %admin ALL = (ALL:ALL) NOPASSWD: ALL\n\tfor _, daemon := range []string{SocketVMNet} {\n\t\tif ok, err := c.IsDaemonInstalled(daemon); err != nil {\n\t\t\treturn err\n\t\t} else if !ok {\n\t\t\tcontinue\n\t\t}\n\t\tuser, err := c.User(daemon)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tcmd = exec.CommandContext(ctx, \"sudo\", \"--user\", user.User, \"--group\", user.Group, \"--non-interactive\", \"true\")\n\t\tlogrus.Infof(\"Running: %v\", cmd.Args)\n\t\tif err := cmd.Run(); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to run %v: %w\", cmd.Args, err)\n\t\t}","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/networks/sudoers.go#L46-L82","documentation":"The passwordless-sudo probe failed while running `sudo -k` to flush the cached sudo credentials. This is the first step of verifying that Lima's network daemons can be started via sudo without a password; if even `sudo -k` fails, sudo itself is broken or unavailable in this environment.","triggerScenarios":"VerifySudoAccess with an empty sudoersFile calls passwordLessSudo, and exec of `sudo -k` returns non-zero — sudo not installed, sudoers misconfigured so even -k requires auth, or the command was killed by context cancellation/timeout.","commonSituations":"Running in a container/CI environment without sudo, a sudoers file with 'Defaults !use_pty' or restricted settings, or the user not in any sudo-enabled group.","solutions":["Ensure sudo is installed and the current user can use it (run `sudo -k` manually)","Fix /etc/sudoers so NOPASSWD rules apply to your group (e.g. '%admin ALL=(ALL) NOPASSWD: ALL')","Generate and install the Lima sudoers file: limactl sudoers | sudo tee /etc/sudoers.d/lima, then set networks.yaml sudoersFile accordingly so the file-based path is used instead","If in CI/container, avoid the sudo-based networks (use usernet/ModeUserV2 networks instead)"],"exampleFix":"// before\n# networks.yaml: paths.sudoersFile == \"\"  → probe path\n// after\n$ limactl sudoers | sudo tee /etc/sudoers.d/lima\n# networks.yaml\npaths:\n  sudoersFile: /etc/sudoers.d/lima","handlingStrategy":"validation","validationCode":"if err := exec.Command(\"sudo\", \"-k\").Run(); err != nil {\n    return fmt.Errorf(\"sudo unavailable or broken on this host: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := verifySudoAccess(ctx); err != nil {\n    if strings.Contains(err.Error(), \"failed to run\") {\n        // fall back to usernet-only networks (no sudo required)\n    }\n}","preventionTips":["Verify `sudo -k` works before installing Lima's sudo-managed networks","In CI/containers, use usernet (ModeUserV2) networks instead of socket_vmnet","Ensure the user belongs to a sudo-enabled group with NOPASSWD","Configure paths.sudoersFile in networks.yaml to skip the fragile probe path"],"tags":["network","sudo","permissions","socket-vmnet"],"backgroundTag":"sudo-password-required","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}