Agent Shell tool runs with empty PATH — basic Unix commands fail (command not found: tr), wasting tokens

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

The Agent/composer Shell tool often executes commands via bare zsh eval with an empty or stripped PATH. Standard Unix utilities (tr, basename, sed, awk, base64, etc.) and user-installed tools then fail with errors like (eval):31: command not found: tr. The integrated terminal on the same machine works fine with a full PATH.

Because failed Shell tool stdout/stderr is rendered into chat, users pay tokens for broken commands. Agents often retry the same logic several ways (longer shell scripts, Python, MCP) before succeeding — multiplying cost.

This is reproducible outside Cursor by simulating the same environment:
env -i HOME="$HOME" PATH= zsh -c 'tr; basename foo' → command not found
zsh -lic 'tr; basename foo; rg --version' → works

Users should not need a ~/.cursor/rules workaround telling agents to wrap every command in zsh -lic.

Steps to Reproduce

  1. macOS Cursor IDE, Agent/Composer chat
  2. Ask the agent to run a multi-line shell loop that uses common utilities (tr, basename, sed, rg, gh, etc.) — e.g. iterate repos and pipe gh api output through tr/rg
  3. Observe Shell tool output: (eval):N: command not found: tr (and rg, basename, base64)
  4. Run the same command in the integrated terminal → succeeds
  5. Wrap the same command in zsh -lic '...' → succeeds in agent Shell too

Minimal repro script that fails bare but works wrapped:

repos=(example)
for repo in "${repos[@]}"; do
  echo "$repo :: $(basename foo/bar.txt)"
  echo test | tr a-z A-Z
done

Expected Behavior

Agent Shell should use the same environment as the user’s integrated terminal — at minimum a login shell with standard PATH (/usr/bin, /bin, /opt/homebrew/bin, user profile paths). Basic Unix commands should work without users adding global rules or wrapping every invocation in zsh -lic.

Operating System

MacOS

Version Information

IDE:
Version: 3.12.29
VSCode Version: 1.128.0
Commit: d5c0e77a0214208f36b56d42e8e787de88d02ea4
OS: Darwin arm64 25.5.0 (macOS 26.5.2)

Additional Information

Impact: burns paid tokens on failed tool output + agent retries. Observed over weeks across multiple agent sessions/projects.

Suggested fix: run agent shell commands through a login shell (zsh -lic / bash -lc) or inherit terminal.integrated.env / user shell profile PATH by default.

Workaround users are forced into: global ~/.cursor/rules requiring zsh -lic on every Shell call.

Does this stop you from using Cursor

Sometimes - I can sometimes use Cursor

Thanks for the detailed report and reproduction. We confirmed this is a bug in how Agent Shell restores the saved zsh environment when it starts with a broken PATH, and we’re tracking a fix internally.

as you mentioned, wrapping affected commands with zsh -lic is a valid workaround. You can also check that ~/.zshenv does not replace PATH with an empty value in non-interactive shells. Will keep you posted with any updates relevant to this.

Hey @David_Mann1!

Expecting a fix for this to ship in v3.14.