{"record":{"id":"aaebf9671b84c1f7","repo":"abiosoft/colima","slug":"error-writing-lima-network-config-file-w","errorCode":null,"errorMessage":"error writing Lima network config file: %w","messagePattern":"error writing Lima network config file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"environment/vm/lima/network.go","lineNumber":56,"sourceCode":"\n\t// if there are no running instances, clear network directory\n\tif instances, err := limautil.RunningInstances(); err == nil && len(instances) == 0 {\n\t\tif err := os.RemoveAll(limautil.NetworkAssetsDirectory()); err != nil {\n\t\t\tlogrus.Warnln(fmt.Errorf(\"could not clear network assets directory: %w\", err))\n\t\t}\n\t}\n\n\tif err := os.MkdirAll(filepath.Dir(networkFile), 0755); err != nil {\n\t\treturn fmt.Errorf(\"error creating Lima config directory: %w\", err)\n\t}\n\n\tnetworkFileMarshalled, err := yaml.Marshal(&defaultLimaNetworkConfig)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error marshalling Lima network config file: %w\", err)\n\t}\n\n\tif err := os.WriteFile(networkFile, networkFileMarshalled, 0755); err != nil {\n\t\treturn fmt.Errorf(\"error writing Lima network config file: %w\", err)\n\t}\n\treturn nil\n}\n\nfunc (l *limaVM) replicateHostAddresses(conf config.Config) error {\n\tif !conf.Network.Address && conf.Network.HostAddresses {\n\t\tfor _, ip := range util.HostIPAddresses() {\n\t\t\tif err := l.RunQuiet(\"sudo\", \"ip\", \"address\", \"add\", ip.String()+\"/24\", \"dev\", \"lo\"); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc (l *limaVM) removeHostAddresses() {\n\tconf, _ := configmanager.LoadInstance()\n\tif !conf.Network.Address && conf.Network.HostAddresses {","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/environment/vm/lima/network.go#L38-L74","documentation":"Error from the Lima network setup when os.WriteFile cannot write the marshalled YAML to the Lima network config file (created with mode 0755). Directory creation and marshalling succeeded; the final write failed.","triggerScenarios":"Existing network config file owned by another user/root, read-only host filesystem, disk full, or an external process (antivirus/backup) holding the file with an exclusive lock at write time.","commonSituations":"~/.lima/_config/networks/default.yaml made root-owned by prior sudo use; macOS disk full; enterprise endpoint protection locking files under ~/.lima during 'colima start'.","solutions":["Check and fix file ownership: sudo chown $(whoami) ~/.lima/_config/networks/default.yaml (path per your Lima layout)","Verify the volume is writable and has space: df -h ~","Temporarily disable/allowlist overzealous file scanners for ~/.lima","Retry 'colima start'"],"exampleFix":"# before: write denied\nsudo chown -R root ~/.lima   # earlier mistake\ncolima start                  # error writing Lima network config file\n# after\nsudo chown -R $(whoami) ~/.lima && colima start","handlingStrategy":"validation","validationCode":"// probe writability of the target file/dir\nfunc canWriteNetworkFile(networkFile string) error {\n    if err := os.MkdirAll(filepath.Dir(networkFile), 0755); err != nil { return err }\n    return os.WriteFile(networkFile+\".probe\", nil, 0644)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check ownership of existing network YAML files after any sudo incident","Exclude ~/.lima from backup/AV locks on managed machines"],"tags":["network","filesystem","permissions","write"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}