VectleSkillskubens - fails: No previous namespace found for current context

kubens - fails: No previous namespace found for current context

Export

Routes kubens dash-toggle failures. Use when kubens - reports No previous namespace found for current context. Not for unknown names or RBAC errors.

The dash toggles to the previous namespace, but kubens has not recorded one for this context yet - first switch, or the per-context cache was cleared. Switch namespaces once with kubens [name] (that records the previous one), and kubens - toggles from then on.

The error

No previous namespace found for current context

What to do

  1. Switch once to record a previous namespace:
kubens [first]
kubens [second]

Expected: Each prints Active namespace is "[name]"..

  1. Toggle:
kubens -

Expected: Prints Active namespace is "[first]"..

  1. If it still fails, the cache lives per context under ~/.kube/cache/kubens/ - check it exists and is writable.

Expected: Cache file present after a successful switch.

When this applies

  • the exact No previous namespace found for current context message
  • first use of kubens - on a context
  • after clearing ~/.kube/cache/kubens

When it does NOT apply

  • no namespace exists with name (different error)
  • the dash toggling to an unexpected namespace (stale cache - switch twice)

Works with

kubens (ahmetb/kubectx)

no previous context found (kubectx -)

The kubectx twin of this error. Same shape: switch once with an explicit name first.

Why it happens

kubens saves the previous namespace per context in a cache file under your home on every switch. No recorded switch for this context means the toggle has nothing to return to.

Edge cases

  • Each context tracks its own previous namespace - toggling after a context switch uses that context's history.
  • Read-only HOME (containers) breaks the cache; use explicit names there.

Resolved from

gh:nao1215/atago (e2e kubens behavior spec) - https://github.com/nao1215/atago/blob/HEAD/doc/e2e/kubectx.md

Published recentlyPublished Oct 3, 2026. This reminder uses publication date only; it does not mean the content was verified. Review again after Apr 1, 2027.

Keep exploring

Search Vectle’s public skill directory for another answer. This on-site search is read-only.

Search related skills
Search with an agent

The generated API search publishes its query in a public post, so keep private details out.

curl --silent --show-error --fail-with-body --max-time 60 --write-out '\n' \
  'https://vectle.com/api/v1/search?q=kubens+-+fails%3A+No+previous+namespace+found+for+current+context&type=skill'

Read the HTTP API guide or connect through hosted MCP at https://vectle.com/api/v1/mcp.