GoogleContainerTools/skaffold · error

retrieving home directory: %w

Error message

retrieving home directory: %w

What it means

GetRemoteCacheDir computes the default remote git cache location under ~/.skaffold/remote-cache when opts.RemoteCacheDir is unset. It throws this wrapped error when the OS home directory cannot be determined via homedir.Dir(), so a cache path cannot be derived.

Source

Thrown at pkg/skaffold/config/remote_cache.go:94

func (s *SyncRemoteCacheOption) CloneDisabled() bool {
	return s.value == never
}

// FetchDisabled specifies if fetching remote dependencies is disabled by flag value
func (s *SyncRemoteCacheOption) FetchDisabled() bool {
	return s.value == missing || s.value == never
}

// GetRemoteCacheDir returns the directory for the remote cache.
func GetRemoteCacheDir(opts SkaffoldOptions) (string, error) {
	if opts.RemoteCacheDir != "" {
		return opts.RemoteCacheDir, nil
	}

	// cache location unspecified, use ~/.skaffold/remote-cache
	home, err := homedir.Dir()
	if err != nil {
		return "", fmt.Errorf("retrieving home directory: %w", err)
	}
	return filepath.Join(home, constants.DefaultSkaffoldDir, "remote-cache"), nil
}

View on GitHub (pinned to a1189de023)

Solutions

  1. Set HOME to a writable directory, e.g. export HOME=/tmp
  2. Set an explicit cache dir via the --remote-cache-dir flag / RemoteCacheDir option so home lookup is skipped
  3. Give the runtime user a real home directory (usermod -d)

Example fix

// before
CMD ["skaffold", "run"]   # HOME unset in container
// after
ENV HOME=/home/skaffold
CMD ["skaffold", "run"]
Defensive patterns

Strategy: fallback

Validate before calling

if os.Getenv("HOME") == "" && opts.RemoteCacheDir == "" {
  os.Setenv("HOME", "/tmp") // or error out early
}

Try / catch

dir, err := config.GetRemoteCacheDir(opts)
if err != nil && strings.Contains(err.Error(), "retrieving home directory") {
  dir = filepath.Join("/tmp", "skaffold-remote-cache")
}

Prevention

When it happens

Trigger: Calling GetRemoteCacheDir (directly or via SyncObjects/syncRepo) with RemoteCacheDir empty while HOME is unset (or the platform home-dir lookup fails, e.g. restricted service accounts or containers without HOME).

Common situations: Running skaffold in minimal Docker/CI containers with no HOME env var; running as a system service user without a home directory; sandboxed environments blocking home-dir detection.

Related errors


AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05). Data as JSON: /api/errors/58d42ba81756ca96. Report an issue: GitHub.