GoogleContainerTools/skaffold · error
retrieving home directory: %w
Error message
retrieving home directory: %w
What it means
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.
Source
Thrown at pkg/skaffold/config/util.go:98
if err != nil {
configFileErr = err
log.Entry(context.TODO()).Warnf("Could not load global Skaffold defaults. Error resolving config file %q", filenameOrDefault)
return
}
configFile, configFileErr = ReadConfigFileNoCache(filenameOrDefault)
if configFileErr == nil {
log.Entry(context.TODO()).Infof("Loaded Skaffold defaults from %q", filenameOrDefault)
}
})
return configFile, configFileErr
}
// ResolveConfigFile determines the default config location, if the configFile argument is empty.
func ResolveConfigFile(configFile string) (string, error) {
if configFile == "" {
home, err := homedir.Dir()
if err != nil {
return "", fmt.Errorf("retrieving home directory: %w", err)
}
configFile = filepath.Join(home, defaultConfigDir, defaultConfigFile)
}
return configFile, util.VerifyOrCreateFile(configFile)
}
// ReadConfigFileNoCache reads the given config yaml file and unmarshals the contents.
// Only visible for testing, use ReadConfigFile instead.
func ReadConfigFileNoCache(configFile string) (*GlobalConfig, error) {
contents, err := os.ReadFile(configFile)
if err != nil {
log.Entry(context.TODO()).Warnf("Could not load global Skaffold defaults. Error encounter while reading file %q", configFile)
return nil, fmt.Errorf("reading global config: %w", err)
}
config := GlobalConfig{}
if err := yaml.Unmarshal(contents, &config); err != nil {
log.Entry(context.TODO()).Warnf("Could not load global Skaffold defaults. Error encounter while unmarshalling the contents of file %q", configFile)
return nil, fmt.Errorf("unmarshalling global skaffold config: %w", err)View on GitHub (pinned to a1189de023)
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
Defensive patterns
Strategy: fallback
Validate before calling
func ensureHome() error {
if os.Getenv("HOME") == "" && runtime.GOOS != "windows" {
return errors.New("HOME is not set; skaffold cannot resolve its global config path")
}
return nil
} Try / catch
configFile, err := config.ResolveConfigFile(flagConfigFile)
if err != nil && strings.Contains(err.Error(), "retrieving home directory") {
home := os.Getenv("HOME")
if home == "" { home = "/tmp" }
configFile = filepath.Join(home, ".skaffold", "config.yaml")
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- retrieving home directory: %w
- reading global config: %w
- normalizing dockerfile path: %w
- getting last log file %w
- writing config to file: %w
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/09e43507855030a0.
Report an issue: GitHub.