Context
Cursor runs AI agent commands in a dedicated shell, not the integrated terminal. That shell sets CURSOR_AGENT=1, is non-interactive login zsh, and often runs inside a sandbox that only allows writes inside the workspace.
Projects pin Node via .nvmrc (e.g. 20.19.6). In a normal interactive terminal, fnm works as expected.
Setup
- OS: macOS
- Shell: zsh
- fnm: Homebrew (
/opt/homebrew/bin/fnm)
- Interactive terminal (
.zshrc):
eval "$(fnm env --use-on-cd --shell zsh)"
- Agent shell (
.zshenv, sourced on every zsh invocation):
if [[ -n "$CURSOR_AGENT" ]]; then
eval "$(fnm env)"
fi
Problem
-
.zshrc is not sourced in the agent shell (interactive=no), so --use-on-cd never runs and .nvmrc is not applied automatically.
-
fnm env fails when initializing in the agent shell:
error: Can't create the symlink for multishells at
"/Users/local_admin/.local/state/fnm_multishells/<pid>_<ts>".
Operation not permitted (os error 1)
fnm creates a new multishell symlink on every shell start. The agent sandbox blocks writes under ~/.local/state/.
any idea how to fix it? or any workaround?
Context
Cursor runs AI agent commands in a dedicated shell, not the integrated terminal. That shell sets
CURSOR_AGENT=1, is non-interactive login zsh, and often runs inside a sandbox that only allows writes inside the workspace.Projects pin Node via
.nvmrc(e.g.20.19.6). In a normal interactive terminal, fnm works as expected.Setup
/opt/homebrew/bin/fnm).zshrc):.zshenv, sourced on every zsh invocation):Problem
.zshrcis not sourced in the agent shell (interactive=no), so--use-on-cdnever runs and.nvmrcis not applied automatically.fnm envfails when initializing in the agent shell:fnm creates a new multishell symlink on every shell start. The agent sandbox blocks writes under
~/.local/state/.any idea how to fix it? or any workaround?