{"record":{"id":"83621c51b0657ca0","repo":"lima-vm/lima","slug":"failed-to-remove-socket-q-w","errorCode":null,"errorMessage":"failed to remove socket %#q: %w","messagePattern":"failed to remove socket %#q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/driver/krunkit/krunkit_driver_darwin_arm64.go","lineNumber":418,"sourceCode":"\nfunc (l *LimaKrunkitDriver) AdditionalSetupForSSH(_ context.Context) error {\n\treturn nil\n}\n\n// Currently, Krunkit does not clean-up the vsock unix socket when the VM stops\n// Issue: https://github.com/containers/krunkit/issues/101\nfunc (l *LimaKrunkitDriver) cleanupStaleSockets() error {\n\tif l.Instance == nil || l.Instance.Dir == \"\" {\n\t\treturn nil\n\t}\n\n\tvar errs []error\n\tfor _, sock := range []string{\n\t\tfilepath.Join(l.Instance.Dir, filenames.GuestAgentSock),\n\t\tfilepath.Join(l.Instance.Dir, sshVsockSock),\n\t} {\n\t\tif err := os.RemoveAll(sock); err != nil {\n\t\t\terrs = append(errs, fmt.Errorf(\"failed to remove socket %#q: %w\", sock, err))\n\t\t}\n\t}\n\n\treturn errors.Join(errs...)\n}\n","sourceCodeStart":400,"sourceCodeEnd":424,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/driver/krunkit/krunkit_driver_darwin_arm64.go#L400-L424","documentation":"At Start time the krunkit driver runs cleanupStaleSockets to delete stale Unix sockets (the guestagent socket and the vsock forwarding socket) from the instance directory. If os.RemoveAll on any of these paths fails, the error is wrapped with `failed to remove socket %#q` and joined into a single error returned to Start.","triggerScenarios":"os.RemoveAll failing on ${instance-dir}/ga.sock (filenames.GuestAgentSock) or the ssh-vsock socket — e.g. permission problems on the instance dir, read-only filesystem, or a file held in a state the OS refuses to remove.","commonSituations":"Instance directory owned by another user or created with root (sudo-started Lima); running Lima home on a network/immutable volume; corrupted instance dir after a crash.","solutions":["Check ownership/permissions of ~/.lima/<instance> and fix: `ls -la` then chown/chmod as needed","Remove the stale socket files manually and retry `limactl start`","If the whole instance is broken, delete it with `limactl delete -f <instance>` and recreate"],"exampleFix":"// before\nsudo limactl start myvm   # creates root-owned files\n// after\nlimactl start myvm        # run as the same user; avoid sudo","handlingStrategy":"try-catch","validationCode":"for _, sock := range []string{\"ga.sock\", \"ssh-vsock.sock\"} {\n    if info, err := os.Stat(filepath.Join(instanceDir, sock)); err == nil && !isWritableDir(instanceDir) {\n        return fmt.Errorf(\"instance dir %s not writable; cannot clean %s\", instanceDir, sock)\n    }\n}","typeGuard":null,"tryCatchPattern":"err := limactl.Start(ctx, inst)\nif strings.Contains(err.Error(), \"failed to remove socket\") {\n    // inspect permissions of the named socket in instance dir, fix, retry\n}","preventionTips":["Never run limactl with sudo (avoids root-owned files)","Keep ${LIMA_HOME} on a local writable volume","After crashes, manually clear stale sockets in the instance dir"],"tags":["krunkit","filesystem","socket","cleanup"],"backgroundTag":"file-permission-denied","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}