{"record":{"id":"2bb8e8f003b79001","repo":"abiosoft/colima","slug":"could-not-load-config-from-file-w","errorCode":null,"errorMessage":"could not load config from file: %w","messagePattern":"could not load config from file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/configmanager/configmanager.go","lineNumber":39,"sourceCode":"func SaveFromFile(file string) error {\n\tc, err := LoadFrom(file)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn Save(c)\n}\n\n// SaveToFile saves configuration to file.\nfunc SaveToFile(c config.Config, file string) error {\n\treturn yamlutil.Save(c, file)\n}\n\n// LoadFrom loads config from file.\nfunc LoadFrom(file string) (config.Config, error) {\n\tvar c config.Config\n\tb, err := os.ReadFile(file)\n\tif err != nil {\n\t\treturn c, fmt.Errorf(\"could not load config from file: %w\", err)\n\t}\n\n\terr = yaml.Unmarshal(b, &c)\n\tif err != nil {\n\t\treturn c, fmt.Errorf(\"could not load config from file: %w\", err)\n\t}\n\n\treturn c, nil\n}\n\n// ValidateConfig validates config before we use it\nfunc ValidateConfig(c config.Config) error {\n\tvalidMountTypes := map[string]bool{\"9p\": true, \"sshfs\": true}\n\tvalidPortForwarders := map[string]bool{\"grpc\": true, \"ssh\": true, \"none\": true}\n\n\tif util.MacOS13OrNewer() {\n\t\tvalidMountTypes[\"virtiofs\"] = true\n\t}","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/config/configmanager/configmanager.go#L21-L57","documentation":"Returned by configmanager.LoadFrom when os.ReadFile fails while reading the YAML config file. The underlying filesystem error is wrapped with %w, so it is typically 'no such file or directory' or 'permission denied'. It fires before any YAML parsing, meaning the file itself could not be read from disk.","triggerScenarios":"Calling configmanager.LoadFrom(file) with a path that does not exist (first run before colima.yaml is generated), a COLIMA_HOME/XDG_CONFIG_HOME location that never received a config, or a file with restrictive permissions or root ownership.","commonSituations":"Fresh machine where 'colima start' has never run; COLIMA_HOME pointing at a custom directory with no colima.yaml; config deleted or moved during cleanup; file created by sudo so the current user cannot read it.","solutions":["Run 'colima start' (or 'colima start --edit') once so the default config file is generated","Verify the path exists and is readable: ls -l on the expected colima.yaml under the active config directory","Fix ownership or permissions if present but unreadable: chown $USER file && chmod 644 file","If the file was deleted intentionally, restore from backup or let colima regenerate defaults"],"exampleFix":"# before: config file was deleted\ncolima start    # error: could not load config from file\n\n# after\ncolima start --edit   # regenerates the config template; save to create the file","handlingStrategy":"try-catch","validationCode":"if _, err := os.Stat(cfgFile); err != nil {\n    if errors.Is(err, fs.ErrNotExist) {\n        // generate config first, e.g. run 'colima start' once\n    }\n    return err // permissions or other stat failure, fix before LoadFrom\n}\nc, err := configmanager.LoadFrom(cfgFile)","typeGuard":null,"tryCatchPattern":"c, err := configmanager.LoadFrom(file)\nif err != nil {\n    var pathErr *os.PathError\n    if errors.As(err, &pathErr) && errors.Is(pathErr.Err, fs.ErrNotExist) {\n        // regenerate the config or fall back to defaults\n    }\n    // unreadable file: surface the wrapped %w cause to the user\n    return err\n}","preventionTips":["Run 'colima start' once on new hosts so colima.yaml exists before any tooling reads it","Pin COLIMA_HOME explicitly in automation so the config path is deterministic","Never create config files with sudo; ownership mismatches make them unreadable later"],"tags":["config","filesystem","yaml"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}