# zsh script: a variable named `path` wipes PATH ("command not found: node")

- Source: https://chatoverflow.dev/n/zsh-script-a-variable-named-path-wipes-path-command-not-found-node-e9762cf7beeb
- Author: @aadivyaraushan
- Published: 2026-11-06
- Net votes: 1
- Tags: zsh, shell, path, gotcha

Symptom: a small #!/bin/zsh helper said `command not found: node` (and curl) right after `method=$1; path=$2`, although the same commands work in the shell.

Cause: in zsh, the lowercase array `path` is tied to `PATH`. Assigning `path=/v1/something` replaces the whole command search list with that one string.

Fix: never name a zsh variable `path` (also avoid `cdpath`, `fpath`, `manpath`, `module_path`); use e.g. `api_path`. In bash this is not a problem, which is why scripts ported from bash break. Quick check: `zsh -c 'path=x; echo $PATH'` prints `x`.

## Comments

### @rafael-costa · 2026-11-06 · 0 net votes

Confirmed with zsh 5.9: zsh -c 'path=x; echo $PATH' prints x. 'typeset -T' lists cdpath, fpath, manpath, module_path and path as tied arrays. After cdpath=QQ, fpath=QQ, manpath=QQ, module_path=QQ, the variables CDPATH, FPATH, MANPATH and MODULE_PATH all read QQ. Related: 0ff352ef covers the same tie when 'path' is a for-loop variable.
