GoogleContainerTools/skaffold · error

getting minikube env: %w

Error message

getting minikube env: %w

What it means

This error wraps a non-zero exit (or execution failure) of the 'minikube docker-env' command itself, reported by util.RunCmdOut. Minikube ran but could not print the Docker environment variables for the given profile — usually because the profile does not exist or the cluster is not running.

Source

Thrown at pkg/skaffold/docker/client.go:233

func getUserAgentHeader() map[string]string {
	userAgent := fmt.Sprintf("skaffold-%s", version.Get().Version)
	log.Entry(context.TODO()).Debugf("setting Docker user agent to %s", userAgent)
	return map[string]string{
		"User-Agent": userAgent,
	}
}

func getMinikubeDockerEnv(ctx context.Context, minikubeProfile string) (map[string]string, error) {
	if minikubeProfile == "" {
		return nil, fmt.Errorf("empty minikube profile")
	}
	cmd, err := cluster.GetClient().MinikubeExec(ctx, "docker-env", "--shell", "none", "-p", minikubeProfile)
	if err != nil {
		return nil, fmt.Errorf("executing minikube command: %w", err)
	}
	out, err := util.RunCmdOut(ctx, cmd)
	if err != nil {
		return nil, fmt.Errorf("getting minikube env: %w", err)
	}

	env := map[string]string{}
	for _, line := range strings.Split(string(out), "\n") {
		if line == "" || strings.HasPrefix(line, "#") {
			continue
		}
		kv := strings.SplitN(line, "=", 2)
		if len(kv) != 2 {
			return nil, fmt.Errorf("unable to parse minikube docker-env keyvalue: %s, line: %s, output: %s", kv, line, string(out))
		}
		if kv[1] == "" {
			continue
		}
		env[kv[0]] = kv[1]
	}

	return env, nil

View on GitHub (pinned to a1189de023)

Solutions

  1. Run 'minikube profile list' to confirm the profile name matches exactly what you passed.
  2. Start the cluster before building: 'minikube -p <profile> start', then retry.
  3. Inspect the wrapped error message for minikube's own output (e.g. 'not found') and act on it.
  4. If the profile is broken, 'minikube -p <profile> delete' and recreate it.

Example fix

// before (cluster never started)
skaffold run --profile minikube
// after
minikube -p minikube start
skaffold run --profile minikube
Defensive patterns

Strategy: retry

Validate before calling

out, err := exec.Command("minikube", "profile", "list").Output()
if err != nil || !strings.Contains(string(out), minikubeProfile) {
    // start the profile before proceeding
    exec.Command("minikube", "-p", minikubeProfile, "start").Run()
}

Try / catch

cli, err := newMinikubeAPIClient(ctx, profile)
if err != nil {
    if strings.Contains(err.Error(), "getting minikube env") {
        // ensure the cluster is running, then retry once
        if err := exec.Command("minikube", "-p", profile, "start").Run(); err == nil {
            cli, err = newMinikubeAPIClient(ctx, profile)
        }
    }
    if err != nil {
        return err
    }
}

Prevention

When it happens

Trigger: newMinikubeAPIClient -> getMinikubeDockerEnv where 'minikube docker-env --shell none -p <profile>' exits non-zero, e.g. profile not found ('profile "x" not found'), cluster stopped, or minikube needs 'minikube start' first.

Common situations: Typo in the minikube profile name; cluster was deleted or never started; minikube's state directory is corrupted; running minikube docker-env against a profile backed by a driver that is unavailable (e.g. VM driver on a VM-less host).

Related errors


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