ahmetb/kubectx · error
you are in a locked single-context shell ("%s"), use 'exit'
Error message
you are in a locked single-context shell ("%s"), use 'exit' to leave What it means
Guard error in checkIsolatedMode: the isolated-shell env var is set and the kubeconfig parsed; the guard returns this message naming the currently locked context (cur), refusing the requested operation because kubectx must not change contexts while a scoped single-context shell is active.
Source
Thrown at cmd/kubectx/isolated_shell_guard.go:23
"os"
"github.com/ahmetb/kubectx/internal/env"
"github.com/ahmetb/kubectx/internal/kubeconfig"
)
func checkIsolatedMode() error {
if os.Getenv(env.EnvIsolatedShell) != "1" {
return nil
}
kc := new(kubeconfig.Kubeconfig).WithLoader(kubeconfig.DefaultLoader)
defer kc.Close()
if err := kc.Parse(); err != nil {
return fmt.Errorf("you are in a locked single-context shell, use 'exit' to leave")
}
cur, _ := kc.GetCurrentContext()
return fmt.Errorf("you are in a locked single-context shell (\"%s\"), use 'exit' to leave", cur)
}
View on GitHub (pinned to 12ad6fb22e)
Solutions
- Type 'exit' to leave the locked shell, then rerun the kubectx command
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at cmd/kubectx/isolated_shell_guard.go:23 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of ahmetb/kubectx@12ad6fb22e (2026-09-02).
Data as JSON: /api/errors/1188f96d1a96bce1.
Report an issue: GitHub.