{"record":{"id":"a280c1a34465d285","repo":"GoogleContainerTools/skaffold","slug":"reading-global-config-w","errorCode":null,"errorMessage":"reading global config: %w","messagePattern":"reading global config: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/config/util.go","lineNumber":111,"sourceCode":"// ResolveConfigFile determines the default config location, if the configFile argument is empty.\nfunc ResolveConfigFile(configFile string) (string, error) {\n\tif configFile == \"\" {\n\t\thome, err := homedir.Dir()\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"retrieving home directory: %w\", err)\n\t\t}\n\t\tconfigFile = filepath.Join(home, defaultConfigDir, defaultConfigFile)\n\t}\n\treturn configFile, util.VerifyOrCreateFile(configFile)\n}\n\n// ReadConfigFileNoCache reads the given config yaml file and unmarshals the contents.\n// Only visible for testing, use ReadConfigFile instead.\nfunc ReadConfigFileNoCache(configFile string) (*GlobalConfig, error) {\n\tcontents, err := os.ReadFile(configFile)\n\tif err != nil {\n\t\tlog.Entry(context.TODO()).Warnf(\"Could not load global Skaffold defaults. Error encounter while reading file %q\", configFile)\n\t\treturn nil, fmt.Errorf(\"reading global config: %w\", err)\n\t}\n\tconfig := GlobalConfig{}\n\tif err := yaml.Unmarshal(contents, &config); err != nil {\n\t\tlog.Entry(context.TODO()).Warnf(\"Could not load global Skaffold defaults. Error encounter while unmarshalling the contents of file %q\", configFile)\n\t\treturn nil, fmt.Errorf(\"unmarshalling global skaffold config: %w\", err)\n\t}\n\treturn &config, nil\n}\n\n// GetConfigForCurrentKubectx returns the specific config to be modified based on the kubeContext.\n// Either returns the config corresponding to the provided or current context,\n// or the global config.\nfunc getConfigForCurrentKubectx(configFile string) (*ContextConfig, error) {\n\tconfigOnce.Do(func() {\n\t\tcfg, err := ReadConfigFile(configFile)\n\t\tif err != nil {\n\t\t\tconfigErr = err\n\t\t\treturn","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/config/util.go#L93-L129","documentation":"ReadConfigFileNoCache reads the global config YAML from disk and wraps os.ReadFile failures with this error. Note it first logs a warning and only then returns the wrapped error — the typical cause is the config file not existing or being unreadable.","triggerScenarios":"Calling ReadConfigFileNoCache with a path that does not exist, has wrong permissions, or is a directory — i.e. os.ReadFile returns any error.","commonSituations":"First run before ~/.skaffold/config.yaml was ever created (usually resolved by VerifyOrCreateFile upstream, but direct calls skip that); file deleted while skaffold runs; permission denied after sudo/chown changes.","solutions":["Ensure the config file exists — run any skaffold command once or call ResolveConfigFile first, which creates the file","Fix file permissions (chmod/chown so the running user can read it)","Verify the configFile path passed is correct and not a directory"],"exampleFix":"// before\ncfg, err := ReadConfigFileNoCache(\"~/.skaffold/config.yaml\") // may not exist\n// after\nconfigFile, err := ResolveConfigFile(\"\")\nif err != nil { return err }\ncfg, err := ReadConfigFileNoCache(configFile)","handlingStrategy":"try-catch","validationCode":"if _, err := os.Stat(configFile); err != nil {\n  if os.IsNotExist(err) { configFile, err = config.ResolveConfigFile(\"\") } // creates it\n} else if info, _ := os.Stat(configFile); info.IsDir() {\n  return errors.New(\"config path is a directory\")\n}","typeGuard":null,"tryCatchPattern":"cfg, err := config.ReadConfigFileNoCache(configFile)\nif err != nil && strings.Contains(err.Error(), \"reading global config\") {\n  log.Warn(\"global config unreadable; using empty defaults\")\n  cfg = &config.GlobalConfig{}\n}","preventionTips":["Create the config via ResolveConfigFile before reading directly","Check file permissions after running with sudo","Avoid deleting ~/.skaffold/config.yaml while skaffold runs"],"tags":["filesystem","config","file-not-found"],"backgroundTag":"config-file-unreadable","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}