Bug Report: Stale Environment Variables in vercel dev
Summary
When removing and re-adding environment variables via the Vercel dashboard or CLI, vercel dev continues to load old values (stale keys) that no longer exist in the project settings. This can persist for >24h, even after multiple redeploys, and causes apps to fail locally with outdated secrets.
Steps to reproduce
-
Create a new env var (e.g.
OPENAI_API_KEY) in Vercel dashboard or via CLI. -
Run
vercel env pull .env.localβ.env.localgets correct value. -
Remove the variable in dashboard/CLI (
vercel env rm OPENAI_API_KEY). -
Add a new value with the same key (
vercel env add OPENAI_API_KEY). -
Run
vercel dev.-
Problem: the app loads the old value of OPENAI_API_KEY, not the updated one. -
Verified by logging prefix/suffix of the key β still using deleted key.
-
Even after hours, caches, restarts β still stale.
-
Expected behavior
vercel dev should always use the current environment values as shown by vercel env ls and vercel env pull.
Actual behavior
-
vercel env lsshows the correct, updated key. -
.env.localcontains the correct, updated key. -
But
vercel devresolves to a different/older value (previously deleted key). -
Seems like some internal cache is serving stale env vars to the local builder runtime.
Workaround
-
Manually delete
.vercel/folder and re-link project (vercel dev). -
Or nuke env var completely, re-add with a different name, then
vercel env pull. -
Only then does
vercel devstop using stale value.
Environment
-
Vercel CLI: 48.1.4
-
OS: Windows 11 (Dev Mode enabled for symlinks)
-
Project type: Node/ESM
-
Happened consistently when rotating API keys (OpenAI).
Suggested fix: ensure vercel dev doesnβt pull stale env vars from cached builders or registry. It should respect the values from vercel env pull or dashboard.