# zsh Tied-Variable Trap <!-- ref: @protocol/zsh-tied-variable-trap tags: [zsh, shell, PATH, debugging, gotcha] triggers: [command not found in a loop, PATH broke mid-script, zsh loop variable, externals fail but builtins work, suspecting a sandbox problem] trigger_prompt: When external commands suddenly fail with 'command not found' inside a shell loop while builtins still work — before theorising about sandboxes or permissions. category: reference version: 1 updated_at: 2026-08-04T17:45:34.205Z --> In zsh, lowercase `path` is a tied array synced to `$PATH`. Naming a loop variable `path` rewrites `$PATH` on the first iteration and every external command after it fails. Each decision below is a section — fetch just one with `?section=<slugified-heading>` rather than pulling the whole branch. --- ## The trap **In zsh, lowercase `path` is a tied array synced to PATH; `read -r id path` clobbers PATH and every subsequent external command fails "command not found". Cost 20 min + false sandbox theory on 2026-07-04.** In zsh, `path` (lowercase) is a special tied array — assigning it rewrites `$PATH`. A `while IFS=$'\t' read -r id path` loop sets PATH to the field value on the first iteration; every external command after that fails with "command not found" while builtins keep working, which masquerades as sandbox/permission weirdness. **Why:** Burned ~20 minutes during the 2026-07-04 archive purge — three dead background loops and a wrong sandbox theory before `echo $PATH` inside the loop exposed it. **How to apply:** In any zsh script or loop, use `epath`, `p`, `fpath_` — never `path` (also avoid other zsh tied names: `cdpath`, `fpath`, `manpath`, `mailpath`). Diagnostic: externals "not found" while `echo` works → print `$PATH` first, not sandbox theories. --- *Related: `@protocol/shell-and-runtime-traps` · `@content/youtube/ai-jason/how-to-install-and-use-claude-code-agent-teams-reverse-engineered` · `@protocol/stuck` · `@protocol/git-pipeline-and-timestamp-traps` · `@protocol/vue-facing-decorator-traps`* --- *You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).* *Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*