GoogleContainerTools/skaffold · error

unmarshalling global skaffold config: %w

Error message

unmarshalling global skaffold config: %w

What it means

Fires in ReadConfigFileNoCache when the contents of the global skaffold config file (~/.skaffold/config) cannot be unmarshalled from YAML into the GlobalConfig struct — i.e. the file exists and is readable but is not valid skaffold config YAML (wrong shape, bad indentation, incompatible fields).

Source

Thrown at pkg/skaffold/config/util.go:116

			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)
	}
	return &config, nil
}

// GetConfigForCurrentKubectx returns the specific config to be modified based on the kubeContext.
// Either returns the config corresponding to the provided or current context,
// or the global config.
func getConfigForCurrentKubectx(configFile string) (*ContextConfig, error) {
	configOnce.Do(func() {
		cfg, err := ReadConfigFile(configFile)
		if err != nil {
			configErr = err
			return
		}
		kubeconfig, err := kubectx.CurrentConfig()
		if err != nil {
			configErr = err
			return

View on GitHub (pinned to a1189de023)

Solutions

  1. Validate and fix YAML syntax, e.g. with `yamllint ~/.skaffold/config.yaml` or a YAML parser
  2. Restore a known-good config (delete the file and let skaffold recreate it: rm ~/.skaffold/config.yaml)
  3. Check the file wasn't truncated by an interrupted run; avoid concurrent skaffold processes writing it

Example fix

# before (broken)
collect_metrics: true
  kubeContext: minikube
# after
collect_metrics: true
kubeContext: minikube
Defensive patterns

Strategy: validation

Validate before calling

func validateGlobalConfigYAML(path string) error {
  b, err := os.ReadFile(path)
  if err != nil { return err }
  var gc config.GlobalConfig
  return yaml.Unmarshal(b, &gc)
}
// call before skaffold runs; on failure back up and delete the file

Try / catch

cfg, err := config.ReadConfigFileNoCache(configFile)
if err != nil && strings.Contains(err.Error(), "unmarshalling") {
  os.Rename(configFile, configFile+".bak")
  configFile, _ = config.ResolveConfigFile("")
  cfg, err = config.ReadConfigFileNoCache(configFile)
}

Prevention

When it happens

Trigger: Calling ReadConfigFileNoCache on a config.yaml containing malformed YAML (bad indentation, tabs, stray characters) or fields with types inconsistent with GlobalConfig.

Common situations: Hand-edited ~/.skaffold/config.yaml with syntax mistakes; partial/corrupt file after an interrupted write; concurrent skaffold processes racing on the same config file; schema drift after upgrading skaffold.

Related errors


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