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, nilView on GitHub (pinned to a1189de023)
Solutions
- Run 'minikube profile list' to confirm the profile name matches exactly what you passed.
- Start the cluster before building: 'minikube -p <profile> start', then retry.
- Inspect the wrapped error message for minikube's own output (e.g. 'not found') and act on it.
- 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
- Always run 'minikube -p <profile> start' before builds against that profile.
- Match profile names exactly against 'minikube profile list'.
- Recreate corrupted profiles with 'minikube -p <profile> delete && minikube -p <profile> start'.
- Verify the container/VM driver works on your host.
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
- getting cluster: %w
- %q running container image %q errored during run with status
- unable to lookup minikube executable. Please add it to PATH
- docker deployment not supported alongside cluster deployment
- INIT_DOCKER_NETWORK_INVALID_MODE
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/848559e47c5ac684.
Report an issue: GitHub.