vercel/next.js · warning
Could not prepare an upgrade retry. This command will…
Error message
Could not prepare an upgrade retry. This command will remain blocked.
What it means
Before showing an upgrade nudge (security, latest, or future), showNudge calls allowNudgeRetry to decide whether the user may be re-prompted. If allowNudgeRetry throws (e.g. its persistence/IO fails), the nudge logic cannot determine retry eligibility, logs this warning, and treats the nudge as still blocked rather than crashing the command.
Solutions
- Fix permissions/disk space in the directory where Next.js stores its state (HOME config/cache dirs).
- Delete the nudge/upgrade state file so it is recreated fresh.
- Re-run the command; if it persists, run with NEXT_TELEMETRY_DISABLED and debug logging to locate the failing IO.
Defensive patterns
Strategy: fallback
Validate before calling
// Ensure the state directory is writable before running commands that nudge
import { accessSync, constants } from 'fs'
function stateDirWritable(dir: string): boolean {
try {
accessSync(dir, constants.W_OK)
return true
} catch {
return false
}
} Try / catch
try {
await runCliCommand()
} catch (e) {
if (String(e).includes('Could not prepare an upgrade retry')) {
// fix HOME/config dir permissions, delete nudge state, re-run
} else throw e
} Prevention
- Keep the user config/cache directory writable (check HOME and disk quota).
- Delete stale nudge state files if upgrade prompts behave oddly.
- In CI, set non-interactive env so nudges don't attempt interactive retries.
When it happens
Trigger: Any `next dev`/`next build`/CLI invocation that triggers nudgeForSecurity/nudgeForLatest/nudgeForFuture while allowNudgeRetry throws — typically a failing state-file read/write or unexpected data in the nudge state store.
Common situations: Read-only or full disk where nudge state cannot be persisted, corrupted nudge state file, or permission errors in the config/cache directory.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- Could not prepare upgrade document
- No Next.js app found in this directory. Run the command…
- Unsupported AI upgrade type
- ${warning}
- AI upgrades are not available for prerelease versions of…
AI-assisted analysis of vercel/next.js@34433fd12e (2026-09-20).
Data as JSON: /api/errors/c23ef0aec2518cf3.
Report an issue: GitHub.
Appendix: source
Thrown at packages/next/src/lib/upgrade/nudge.ts:115
}
await writeRetry(receipt, Date.now())
return false
}
async function showNudge(
options: SecurityNudgeOptions,
version: string,
kind: NudgeKind,
prompt: string,
warning: string,
errorName: string
): Promise<void> {
let retryAllowed = false
try {
retryAllowed = await allowNudgeRetry(options, version, kind)
} catch {
Log.warn(
'Could not prepare an upgrade retry. This command will remain blocked.'
)
}
if (retryAllowed) {
Log.warn(warning)
return
}
const error = new Error(prompt)
error.name = errorName
Object.assign(error, { exitCode: 1 })
throw error
}
async function getLatestUpgrade(
installedVersion: string = process.env.__NEXT_VERSION || 'unknown'
): Promise<{ installedVersion: string; latestVersion: string } | null> {View on GitHub (pinned to 34433fd12e)