kubernetes/minikube · error
run extract.go from the minikube root directory
Error message
run extract.go from the minikube root directory
What it means
The extract tool requires being launched from the minikube repository root because it scans hardcoded relative paths ("cmd", "pkg") and writes to translations/. This panic is a deliberate guard: it calls os.Getwd() and panics if the returned path contains the substring "cmd", which happens when the tool is run from inside cmd/extract rather than from the repo root. Note the check is substring-based, so any parent directory containing "cmd" (e.g. a checkout at /home/user/cmd/minikube or C:\cmd\minikube) also trips it even from the root.
Source
Thrown at cmd/extract/extract.go:43
import (
"os"
"strings"
"k8s.io/minikube/pkg/minikube/extract"
)
func main() {
paths := []string{"cmd", "pkg"}
functions := []string{"translate.T"}
outDir := "translations"
cwd, err := os.Getwd()
if err != nil {
panic("Getting current working directory failed")
}
if strings.Contains(cwd, "cmd") {
panic("run extract.go from the minikube root directory")
}
if _, err = os.Stat(extract.ErrMapFile); os.IsNotExist(err) {
panic("err_map.go doesn't exist")
}
err = extract.TranslatableStrings(paths, functions, outDir)
if err != nil {
panic(err)
}
}
View on GitHub (pinned to a899afc0eb)
Solutions
- Change to the minikube repository root and run `go run cmd/extract/extract.go` (or `go run ./cmd/extract`) from there.
- If you are already at the root but still hit the panic, your checkout path contains "cmd" somewhere; move/rename the checkout (e.g. /home/user/src/minikube) so the substring check no longer matches.
- As a maintainer improvement, replace the substring test with an exact check such as filepath.Base(cwd) == "minikube" or os.Stat("pkg/minikube/reason/known_issues.go").
Example fix
// before
if strings.Contains(cwd, "cmd") {
panic("run extract.go from the minikube root directory")
}
// after
if filepath.Base(cwd) != "minikube" {
panic("run extract.go from the minikube root directory")
} Defensive patterns
Strategy: validation
Validate before calling
// Run before executing the tool: verify you are at the repo root.
cwd, _ := os.Getwd()
if filepath.Base(cwd) != "minikube" {
log.Fatal("run extract.go from the minikube root directory")
}
// Shell equivalent before `go run cmd/extract/extract.go`:
// [ "$(basename "$PWD")" = minikube ] || { echo "cd to minikube root first"; exit 1; } Prevention
- Always launch the tool from the repository root: `go run ./cmd/extract`, never from inside cmd/extract.
- Keep checkouts out of paths containing "cmd" as a substring, since the current guard matches any parent (e.g. avoid /home/user/cmd/minikube).
- Prefer an exact root check (filepath.Base(cwd), or stat of a root-only marker file) over substring matching when patching the guard.
- Document the launch requirement in the tool's package comment so contributors do not discover it via panic.
When it happens
Trigger: Running the tool with the shell's cwd inside cmd/ or cmd/extract (e.g. `cd cmd/extract && go run extract.go`); or, as a false positive, running from a correctly rooted checkout whose absolute path merely contains "cmd" as a substring of some parent directory.
Common situations: A developer cds into the file's directory in their editor's integrated terminal and runs go run there; a machine whose workspace lives under a path like /srv/cmd-work/minikube or D:\cmd\minikube on Windows, which trips the substring check even though the cwd is the repo root.
Related errors
AI-assisted analysis of kubernetes/minikube@a899afc0eb (2026-08-15).
Data as JSON: /api/errors/4f393a6f959824df.
Report an issue: GitHub.