{"record":{"id":"09e43507855030a0","repo":"GoogleContainerTools/skaffold","slug":"retrieving-home-directory-w-09e435","errorCode":null,"errorMessage":"retrieving home directory: %w","messagePattern":"retrieving home directory: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/config/util.go","lineNumber":98,"sourceCode":"\t\tif err != nil {\n\t\t\tconfigFileErr = err\n\t\t\tlog.Entry(context.TODO()).Warnf(\"Could not load global Skaffold defaults. Error resolving config file %q\", filenameOrDefault)\n\t\t\treturn\n\t\t}\n\t\tconfigFile, configFileErr = ReadConfigFileNoCache(filenameOrDefault)\n\t\tif configFileErr == nil {\n\t\t\tlog.Entry(context.TODO()).Infof(\"Loaded Skaffold defaults from %q\", filenameOrDefault)\n\t\t}\n\t})\n\treturn configFile, configFileErr\n}\n\n// 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)","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/config/util.go#L80-L116","documentation":"ResolveConfigFile derives the default global config path (~/.skaffold/config.yaml) when no configFile argument is given. It throws this wrapped error when homedir.Dir() fails, because the config location cannot be determined; the error then propagates to all config read/update helpers.","triggerScenarios":"Calling ResolveConfigFile (or any caller like WriteFullConfig, UpdateMsgDisplayed, UpdateHaTSSurveyTaken, UpdateGlobalCollectMetrics) with an empty configFile while the OS home directory is unresolvable (HOME unset, service account without home).","commonSituations":"Containers or CI jobs running without HOME set; running skaffold as a daemon/system user with no home; Kerberos/nsswitch misconfiguration on Linux breaking home lookup.","solutions":["Set the HOME environment variable to a writable directory","Pass an explicit --config-file path so home lookup is skipped","Ensure the executing user has a valid passwd entry with a home directory"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"func ensureHome() error {\n  if os.Getenv(\"HOME\") == \"\" && runtime.GOOS != \"windows\" {\n    return errors.New(\"HOME is not set; skaffold cannot resolve its global config path\")\n  }\n  return nil\n}","typeGuard":null,"tryCatchPattern":"configFile, err := config.ResolveConfigFile(flagConfigFile)\nif err != nil && strings.Contains(err.Error(), \"retrieving home directory\") {\n  home := os.Getenv(\"HOME\")\n  if home == \"\" { home = \"/tmp\" }\n  configFile = filepath.Join(home, \".skaffold\", \"config.yaml\")\n}","preventionTips":["Export HOME in CI/containers before invoking skaffold","Pass --config-file explicitly in headless environments","Ensure the running user has a valid passwd home entry"],"tags":["filesystem","home-directory","config"],"backgroundTag":"home-directory-unresolved","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"}