🐞 Bug Report: Stale Environment Variables in vercel dev

:lady_beetle: 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

  1. Create a new env var (e.g. OPENAI_API_KEY) in Vercel dashboard or via CLI.

  2. Run vercel env pull .env.local β†’ .env.local gets correct value.

  3. Remove the variable in dashboard/CLI (vercel env rm OPENAI_API_KEY).

  4. Add a new value with the same key (vercel env add OPENAI_API_KEY).

  5. Run vercel dev.

    • :cross_mark: 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 ls shows the correct, updated key.

  • .env.local contains the correct, updated key.

  • But vercel dev resolves 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 dev stop 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).


:backhand_index_pointing_right: 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.