wrangler-4-111-0-0-b
Claude Code's read-only tools, web search on, ludion sync on
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) no longer accepts the `legacy_env` field. Its config validation now treats any `legacy_env` key as an error, which is why deploys fail (`node_modules/wrangler/wrangler-dist/cli.js:20314`). Service environments have been removed. Each environment now deploys as its own Worker named `<name>-<environment>`, which is what `legacy_env = true` already did, and that was the default. So the fix is to delete the line. Nothing else changes, and your Worker deploys the same way as before.
The 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"
}
```
The `wrangler.jsonc` in this directory already looks like that and has no `legacy_env`. If deploys still fail, check whether a different config file or an environment-specific one still sets it.Grade
correct
The judge's reason: It says the legacy_env field now errors, service environments are removed, and each environment deploys as its own <name>-<environment> Worker, with no stale claims.
Session log
Tool call: Glob
{ "pattern": "wrangler.*" }Tool output
wrangler.jsonc node_modules\wrangler\bin\wrangler.js node_modules\.bin\wrangler.cmd node_modules\.bin\wrangler.ps1Tool call: Bash
{ "command": "cd \"C:/Users/haya0/AppData/Local/Temp/ludion-bench-9geni9/work\" && ls -a && cat package.json 2>/dev/null; ls node_modules/wrangler 2>/dev/null | head", "description": "List project files and check wrangler install" }Tool output
. .. .ludion CLAUDE.md node_modules package-lock.json package.json src wrangler.jsonc { "name": "bench-wrangler", "private": true, "type": "module", "scripts": { "dev": "wrangler dev", "deploy": "wrangler deploy" }, "devDependencies": { "wrangler": "4.148.0" } } README.md bin config-schema.json kv-asset-handler.js package.json templates wrangler-distTool call: Bash
{ "command": "cd \"C:/Users/haya0/AppData/Local/Temp/ludion-bench-9geni9/work\" && cat wrangler.jsonc; grep -o '.\\{300\\}legacy_env.\\{300\\}' node_modules/wrangler/wrangler-dist/cli.js | head -5; grep -n -i legacy_env node_modules/wrangler/config-schema.json | head", "description": "Show config and search wrangler source for legacy_env" }Tool output
{ "name": "bench-worker", "main": "src/index.js", "compatibility_date": "2026-10-01" }Tool call: Bash
{ "command": "cd \"C:/Users/haya0/AppData/Local/Temp/ludion-bench-9geni9/work\" && grep -rl -i \"legacy_env\\|legacyEnv\" node_modules/wrangler/wrangler-dist | head; grep -o -i '.\\{200\\}legacy.env.\\{200\\}' -r node_modules/wrangler/wrangler-dist | head -5", "description": "Search wrangler dist 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-9geni9/work\" && grep -n -i -o '.\\{0,250\\}legacy_\\?env.\\{0,250\\}' node_modules/wrangler/wrangler-dist/cli.js | head -8", "description": "Show legacy_env context in wrangler cli" }Tool output (error)
This Bash command contains multiple operations. The following part requires approval: cd "C:/Users/haya0/AppData/Local/Temp/ludion-bench-9geni9/work" && grep -n -i -o '.\{0,250\}legacy_\?env.\{0,250\}' node_modules/wrangler/wrangler-dist/cli.jsTool call: Grep
{ "pattern": ".{0,250}legacy_?env.{0,250}", "path": "C:\\Users\\haya0\\AppData\\Local\\Temp\\ludion-bench-9geni9\\work\\node_modules\\wrangler\\wrangler-dist\\cli.js", "output_mode": "content", "-o": true, "-i": true, "head_limit": 8 }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; 158925: return typeof error53 === "object" && error53 !== null && "code" in error53 && (error53.code === WORKER_NOT_FOUND_ERR_CODE || error53.code === WORKER_LEGACY_ENVIRONMENT_NOT_FOUND_ERR_CODE); 158927:var WORKER_NOT_FOUND_ERR_CODE, WORKER_LEGACY_ENVIRONMENT_NOT_FOUND_ERR_CODE; 158932: WORKER_LEGACY_ENVIRONMENT_NOT_FOUND_ERR_CODE = 10090;Tool call: Read
{ "file_path": "C:\\Users\\haya0\\AppData\\Local\\Temp\\ludion-bench-9geni9\\work\\node_modules\\wrangler\\wrangler-dist\\cli.js", "offset": 20310, "limit": 18 }Tool output
20310 rawConfig, 20311 configPath, 20312 userConfigPath 20313 ); 20314 if ("legacy_env" in rawConfig) { 20315 if (!isRedirectedConfig2) { 20316 diagnostics.errors.push( 20317 dedent` 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. 20320 Refer to https://developers.cloudflare.com/workers/wrangler/environments/ for more information. 20321 ` 20322 ); 20323 } 20324 delete rawConfig.legacy_env; 20325 } 20326 validateOptionalProperty( 20327 diagnostics,Agent
Your installed wrangler (4.148.0) no longer accepts the `legacy_env` field. Its config validation now treats any `legacy_env` key as an error, which is why deploys fail (`node_modules/wrangler/wrangler-dist/cli.js:20314`). Service environments have been removed. Each environment now deploys as its own Worker named `<name>-<environment>`, which is what `legacy_env = true` already did, and that was the default. So the fix is to delete the line. Nothing else changes, and your Worker deploys the same way as before. The 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" } ``` The `wrangler.jsonc` in this directory already looks like that and has no `legacy_env`. If deploys still fail, check whether a different config file or an environment-specific one still sets it.