{"record":{"id":"d82cc9d85ce76be0","repo":"lima-vm/lima","slug":"failed-to-build-network-arguments-w","errorCode":null,"errorMessage":"failed to build network arguments: %w","messagePattern":"failed to build network arguments: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/driver/krunkit/krunkit_darwin_arm64.go","lineNumber":86,"sourceCode":"\t\t\tif disk.Instance != \"\" {\n\t\t\t\treturn nil, fmt.Errorf(\"failed to run attach disk %#q, in use by instance %#q\", disk.Name, disk.Instance)\n\t\t\t}\n\t\t\tif lerr := disk.Lock(inst.Dir); lerr != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"failed to lock disk %#q: %w\", d.Name, lerr)\n\t\t\t}\n\t\t\textraDiskPath := filepath.Join(disk.Dir, filenames.DataDisk)\n\t\t\tlogrus.Infof(\"Mounting disk %#q on %#q\", disk.Name, disk.MountPoint)\n\t\t\tif cerr := diskUtil.Convert(ctx, raw.Type, extraDiskPath, extraDiskPath, nil, true); cerr != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"failed to convert extra disk %#q to raw: %w\", extraDiskPath, cerr)\n\t\t\t}\n\t\t\targs = append(args, \"--device\", fmt.Sprintf(\"virtio-blk,path=%s,format=raw\", extraDiskPath))\n\t\t}\n\t}\n\n\t// Network commands\n\tnetworkArgs, err := buildNetworkArgs(inst)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to build network arguments: %w\", err)\n\t}\n\n\t// File sharing commands\n\tif *inst.Config.MountType == limatype.VIRTIOFS {\n\t\tfor _, mount := range inst.Config.Mounts {\n\t\t\tif _, err := os.Stat(mount.Location); errors.Is(err, os.ErrNotExist) {\n\t\t\t\tif err := os.MkdirAll(mount.Location, 0o750); err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t}\n\t\t\ttag := limayaml.MountTag(mount.Location, *mount.MountPoint)\n\t\t\tmountArg := fmt.Sprintf(\"virtio-fs,sharedDir=%s,mountTag=%s\", mount.Location, tag)\n\t\t\targs = append(args, \"--device\", mountArg)\n\t\t}\n\t}\n\n\targs = append(args, networkArgs...)\n","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/driver/krunkit/krunkit_darwin_arm64.go#L68-L104","documentation":"Cmdline delegates all network device flag construction to buildNetworkArgs; any error returned there (invalid network spec, missing socket_vmnet, socket path failures, usernet socket errors) is wrapped as `failed to build network arguments: %w`. It is a generic wrapper meaning 'the instance's networks config could not be translated into krunkit --device flags'.","triggerScenarios":"Calling Start/Cmdline on an instance whose networks array contains a spec buildNetworkArgs rejects (unknown nw.Lima mode, neither Lima nor Socket set), socket_vmnet not installed for shared/bridged mode, or usernet/socket path resolution failing.","commonSituations":"Misconfigured `networks:` entries in lima.yaml; referencing a named network not defined in networks.yaml; socket_vmnet absent on macOS; typo'd socket path. The useful detail is in the wrapped cause.","solutions":["Inspect the wrapped `%w` cause and fix accordingly (install socket_vmnet, fix the network name, etc.).","Validate `networks:` entries in the instance lima.yaml: each needs either a valid `lima:` mode (shared/bridged/user-v2) or a `socket:` path.","Check ~/.lima/_config/networks.yaml defines any named networks referenced by the instance.","If only basic connectivity is needed, remove custom networks entries so the default slirp/usernet path is used."],"exampleFix":"# before (lima.yaml)\nnetworks:\n  - lima: shared   # socket_vmnet missing\n# after\nnetworks:\n  - lima: user-v2\n# or install socket_vmnet: brew install socket_vmnet + limactl sudoers","handlingStrategy":"try-catch","validationCode":"# Shell: sanity-check network entries before start\nyq '.networks[] | select((.lima == null) and (.socket == null))' lima.yaml | grep . && { echo \"network entry missing lima/socket\"; exit 1; }","typeGuard":"func validNetworkSpec(nw Network) bool {\n    return nw.Lima == \"user-v2\" || nw.Lima == \"shared\" || nw.Lima == \"bridged\" || nw.Socket != \"\"\n}","tryCatchPattern":"if _, err := d.Cmdline(inst); err != nil {\n    if cause := errors.Unwrap(err); cause != nil {\n        log.Errorf(\"network config problem: %v\", cause) // inspect wrapped cause\n    }\n    return err\n}","preventionTips":["Only use lima modes shared/bridged/user-v2 or explicit socket entries with krunkit","Install socket_vmnet if shared/bridged networking is required","Validate lima.yaml with limactl start --print before scripting starts","Unwrap the error to find the specific network failure"],"tags":["krunkit","network","macos","config"],"backgroundTag":"network-args-build-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}