As Cursor doesn’t create a login shell, Mise isn’t loaded automatically.
I added ~/.cursor/hooks/mise-shell.sh which solves this problem.
The issue is that Cursor can break at one point and it starts to show “Canceled: Canceled” for all hook calls. I have to restart Cursor to make mise with hooks work again.
Steps to Reproduce
I don’t know how to reproduce the hooks starting to break.
On the hooks failing, that’s not great. Next time it happens, could you try Cmd+Shift+P → Restart Extension Host and let me know if that alone brings the hooks back? Hooks run in the extension host, so if a restart fixes it that points the blame squarely there and helps us narrow it down.
On mise itself, you shouldn’t actually need a hook for this. The agent runs commands in a non-login, non-interactive shell, and the standard mise activate relies on a per-directory shell hook (chpwd) that never fires there. So the agent ends up frozen on whatever versions were resolved when Cursor launched, rather than your project’s pinned versions.
The fix is to use shims, which resolve the correct tool version at run-time regardless of shell type. mise recommends exactly this for editors (IDE integration docs).
The one thing that matters is that the shims dir ends up first on PATH, ahead of any hook-mode entries or other version managers. The most reliable way is to add this as the last line of your ~/.zshrc, after any existing setup and restart Cursor.
When it next happens, does Cmd+Shift+P → Restart Extension Host recover it without a full restart? That tells us whether it’s the extension host wedging.
Could you grab logs from around when it breaks? Cmd+Shift+P → Developer: Open Logs Folder, and the Output panel channels for the agent/hooks would be ideal.
The errors changed now: “Error: MainThreadShellExec not initialized”.
It is not a per-call flake. It flips between long healthy and broken windows.
I asked Cursor to find relevant information in the logs, here is the response:
The MainThreadShellExec not initialized errors are a Cursor-side shell runner failure when launching your user preToolUse hook — the script never starts.
Verdict
Intermittent Cursor bug: hook process fails to spawn (exit code: N/A, 0ms). Your hooks/mise-shell.sh is fine when ShellExec is ready (~1458 successes vs ~220 failures this session).
Found 1 hook(s) to execute for step: preToolUse
Executing hook 1/1 from user config
Running script in directory: /Users/XXX/.cursor
Running hook 1 with timeout 5000ms
Command: hooks/mise-shell.sh (0ms) exit code: N/A
INPUT: Shell → ls / head / ls …
OUTPUT: (empty)
ERROR: Error executing hook 1
Error: MainThreadShellExec not initialized
All hooks for step preToolUse completed but none returned a valid response
This is Cursor’s guess about this error: “Critical side-effect path (agent hooks) depended on a lazily initialized, window-scoped main-thread service. When that service was disposed or never rebound, callers blocked ~10s and failed with “not initialized,” even though the hook script itself was healthy.”