kubernetes/minikube · error
Getting current working directory failed
Error message
Getting current working directory failed
What it means
cmd/extract/extract.go is a maintainer tool that extracts translate.T strings from cmd/ and pkg/ into the translations/ directory. Before doing anything it calls os.Getwd(), and if the Go runtime cannot return the process working directory it panics with 'Getting current working directory failed'. On Linux this almost always means the current directory was deleted while the shell still sat in it (the inode is gone, so getcwd(2) fails). It is an environment failure, not a code bug in minikube itself.
Source
Thrown at cmd/extract/extract.go:39
Usage: from the root minikube directory, go run cmd/extract/extract.go
*/
package main
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
- Run `pwd` in the same shell; if it errors or shows a stale path, `cd` back into a directory that exists (the minikube repo root).
- Re-create or re-clone the workspace if it was deleted, then re-run from the minikube root.
- If in CI, ensure the cleanup step that removes the workspace runs after, not before, the extract tool.
- Optionally wrap the cause in the panic (fmt.Errorf with %w) so the next failure shows the underlying errno.
Example fix
// before
cwd, err := os.Getwd()
if err != nil {
panic("Getting current working directory failed")
}
// after
cwd, err := os.Getwd()
if err != nil {
panic(fmt.Errorf("getting current working directory failed: %w", err))
} Defensive patterns
Strategy: try-catch
Validate before calling
if _, err := os.Stat("."); err != nil {
log.Fatalf("working directory is not accessible: %v", err)
} Try / catch
defer func() {
if r := recover(); r != nil {
log.Fatalf("extract failed: %v", r)
}
}()
cwd, err := os.Getwd()
if err != nil {
panic(fmt.Errorf("getting current working directory failed: %w", err))
} Prevention
- Run `pwd` (or check the terminal prompt) before invoking the tool; a stale prompt after a `git clean` means the directory is gone.
- In CI, invoke the tool with an explicit working directory (e.g. `dir:` step) instead of relying on an inherited cwd.
- Wrap panics with fmt.Errorf and %w so getcwd errno details survive into the panic message.
- Avoid running long-lived shells inside temp workspaces that automated cleanup may delete.
When it happens
Trigger: Running `go run cmd/extract/extract.go` from a directory that was removed or renamed out from under the process (common after `git clean -dxf` or deleting a worktree in another terminal); a container/sandbox where the cwd is unlinked or unreadable; on Windows, a cwd with a dropped UNC share.
Common situations: A CI job that cds into a temp workspace that a previous cleanup step deleted; a developer whose terminal is inside a directory removed by `git clean`; running the tool from an unmounted or permission-revoked path.
Related errors
AI-assisted analysis of kubernetes/minikube@a899afc0eb (2026-08-15).
Data as JSON: /api/errors/b4b0cd4aff92c528.
Report an issue: GitHub.