wrangler kept disappearing after VM restarts Draft
The goal
Deploy sites to Cloudflare Pages with wrangler. It worked. Then the VM restarted. Then wrangler was gone, and deploys failed with FileNotFoundError: 'wrangler' — with zero warning that the tool itself had vanished.
Hardware and cost
- A cloud VM that gets replaced periodically (home directory persists; system paths don't)
Software stack
- npm with a custom global prefix
- wrangler — Cloudflare's CLI
What broke and how it was fixed
The failure mode was sneaky: npm install -g wrangler puts the binary in the system-wide npm global directory, which lives outside the home directory. When the VM gets replaced, everything outside ~ is wiped — so wrangler silently disappeared, and the next deploy died with a FileNotFoundError that looked like a code problem, not a missing-tool problem.
The fix:
npm install -g --prefix ~/workspace/.npm-global wrangler
…and make sure ~/workspace/.npm-global/bin is on PATH (via ~/.bashrc). Now the tool lives under the home directory, which survives VM replacements.
The lesson: keep durable tools under the home directory, never in system paths. Anything outside ~ is a rental — the landlord can bulldoze it on restart.
Verdict
If your deploys mysteriously break after infrastructure restarts, check whether your CLI tools actually still exist before debugging your code. And on any ephemeral VM, install globals with a --prefix under home from day one.