wrangler-4-111-0-0-b
Claude Code's read-only tools, web search on, ludion sync off
Question
My wrangler config sets legacy_env = true and deploys now fail. What happened, and what should the config look like?
Answer key
- A correct answer says
- Wrangler no longer supports service environments: the `legacy_env` field and `--legacy-env` flag are gone (the field now raises an error) and every environment deploys as its own Worker named <name>-<environment>.
- The stale answer
- You can set `legacy_env = false` in wrangler.toml to use service environments, where all environments belong to one Worker.
Answer
Your installed Wrangler (4.148.0) has dropped the `legacy_env` field. Any config that contains it now fails validation with an error. I found the check in `node_modules/wrangler/wrangler-dist/cli.js:20314`, and its error message says "The 'legacy_env' field is no longer supported, so please remove it." Service environments have been removed, so each environment always deploys as its own Worker named `<name>-<environment>`. That is exactly what `legacy_env = true` did, and it was already the default.
The fix is to delete the `legacy_env` line. How your Workers deploy won't change. The `wrangler.jsonc` in this directory doesn't contain `legacy_env`, so I couldn't see your exact file, but the cleaned-up config should look like this, with any `env` blocks kept as they are:
```jsonc
{
"name": "bench-worker",
"main": "src/index.js",
"compatibility_date": "2026-10-01"
// "env": { "staging": { ... } } → deploys as "bench-worker-staging"
}
```Grade
correct
The judge's reason: It says the legacy_env field was removed and now errors, that service environments are gone, and that each environment deploys as <name>-<environment>, with no stale claim.
Session log
Tool call: Bash
{ "command": "cd \"C:/Users/haya0/AppData/Local/Temp/ludion-bench-zLAJfg/work\" && ls -la && cat wrangler.* package.json 2>/dev/null | head -80", "description": "List project files and show wrangler config" }Tool output
total 66 drwxr-xr-x 1 haya0 197609 0 Oct 11 19:42 . drwxr-xr-x 1 haya0 197609 0 Oct 11 19:42 .. drwxr-xr-x 1 haya0 197609 0 Oct 11 19:42 node_modules -rw-r--r-- 1 haya0 197609 50058 Oct 11 09:33 package-lock.json -rw-r--r-- 1 haya0 197609 187 Oct 11 09:32 package.json drwxr-xr-x 1 haya0 197609 0 Oct 11 19:42 src -rw-r--r-- 1 haya0 197609 93 Oct 11 09:32 wrangler.jsonc { "name": "bench-worker", "main": "src/index.js", "compatibility_date": "2026-10-01" } { "name": "bench-wrangler", "private": true, "type": "module", "scripts": { "dev": "wrangler dev", "deploy": "wrangler deploy" }, "devDependencies": { "wrangler": "4.148.0" } }Tool call: Bash
{ "command": "cd \"C:/Users/haya0/AppData/Local/Temp/ludion-bench-zLAJfg/work\" && grep -o '\"version\": *\"[^\"]*\"' node_modules/wrangler/package.json; grep -rhoE '.{200}legacy_env.{300}' node_modules/wrangler/wrangler-dist/cli.js | head -8", "description": "Check wrangler version and legacy_env handling" }Tool output
"version": "4.148.0"Tool call: Bash
{ "command": "cd \"C:/Users/haya0/AppData/Local/Temp/ludion-bench-zLAJfg/work\" && grep -rlE 'legacy_env|legacyEnv' node_modules/wrangler --include=*.js --include=*.md --include=*.json 2>/dev/null | head; grep -rhoE '.{250}(legacy_env|legacyEnv).{350}' node_modules/wrangler --include=*.js 2>/dev/null | head -6", "description": "Search wrangler package for legacy_env references" }Tool output
node_modules/wrangler/wrangler-dist/cli.jsTool call: Bash
{ "command": "cd \"C:/Users/haya0/AppData/Local/Temp/ludion-bench-zLAJfg/work\" && grep -nE 'legacy_env|legacyEnv' node_modules/wrangler/wrangler-dist/cli.js | cut -c1-600 | head -20", "description": "Show legacy_env lines in wrangler CLI" }Tool output
20314: if ("legacy_env" in rawConfig) { 20318: The "legacy_env" field is no longer supported, so please remove it from your configuration file. 20319: Service environments have been removed, and each environment is now deployed as its own Worker named "<name>-<environment>". This matches the behaviour of "legacy_env = true", which was the default, so removing the field will not change how your Worker is deployed. 20324: delete rawConfig.legacy_env;Tool call: Bash
{ "command": "cd \"C:/Users/haya0/AppData/Local/Temp/ludion-bench-zLAJfg/work\" && sed -n 20305,20330p node_modules/wrangler/wrangler-dist/cli.js", "description": "Show surrounding code for legacy_env check" }Tool output
function normalizeAndValidateConfig(rawConfig, configPath, userConfigPath, args, preserveOriginalMain = false) { const diagnostics = new Diagnostics( `Processing ${configPath ? path28__namespace.default.relative(process.cwd(), configPath) : "wrangler"} configuration:` ); const isRedirectedConfig2 = isRedirectedRawConfig( rawConfig, configPath, userConfigPath ); if ("legacy_env" in rawConfig) { if (!isRedirectedConfig2) { diagnostics.errors.push( dedent` The "legacy_env" field is no longer supported, so please remove it from your configuration file. Service environments have been removed, and each environment is now deployed as its own Worker named "<name>-<environment>". This matches the behaviour of "legacy_env = true", which was the default, so removing the field will not change how your Worker is deployed. Refer to https://developers.cloudflare.com/workers/wrangler/environments/ for more information. ` ); } delete rawConfig.legacy_env; } validateOptionalProperty( diagnostics, "", "send_metrics", rawConfig.send_metrics,Agent
Your installed Wrangler (4.148.0) has dropped the `legacy_env` field. Any config that contains it now fails validation with an error. I found the check in `node_modules/wrangler/wrangler-dist/cli.js:20314`, and its error message says "The 'legacy_env' field is no longer supported, so please remove it." Service environments have been removed, so each environment always deploys as its own Worker named `<name>-<environment>`. That is exactly what `legacy_env = true` did, and it was already the default. The fix is to delete the `legacy_env` line. How your Workers deploy won't change. The `wrangler.jsonc` in this directory doesn't contain `legacy_env`, so I couldn't see your exact file, but the cleaned-up config should look like this, with any `env` blocks kept as they are: ```jsonc { "name": "bench-worker", "main": "src/index.js", "compatibility_date": "2026-10-01" // "env": { "staging": { ... } } → deploys as "bench-worker-staging" } ```