Cursor doesn't work reliably when using mise

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

I am using Mise to manage dependency versions.

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.

Operating System

MacOS

Version Information

Version: 3.8.11 (Universal)
VS Code Extension API: 1.105.1
Commit: e56ad3440df06d22ca7501e65fd518e905486ef0
Date: 2026-06-18T01:40:18.333Z
Layout: glass
Build Type: Stable
Release Track: Default
Electron: 40.10.3
Chromium: 144.0.7559.236
Node.js: 24.15.0
V8: 14.4.258.32-electron.0
xterm.js: 6.1.0-beta.256
OS: Darwin arm64 25.5.0

For AI issues: which model did you use?

Auto

Does this stop you from using Cursor

Sometimes - I can sometimes use Cursor

Hey @afsuk

Thanks for the report!

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.

export PATH="$HOME/.local/share/mise/shims:$PATH"

Thanks for the reply. Unfortunately binaries are only one side of the problem, I also rely on mise setting environment variables hence using a hook.

Thanks for the context!

  • 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.
  • Does it affect all hooks at once, or just some?

I didn’t find a “Restart Extension Host” command.

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).

Primary log files

window1_wb1/output_20260718T112238/cursor.hooks.workspaceId-10b7114967450505a0358bc8439f89cb.log

118 failures

2026-07-18 11:16 → 07-19 11:33

window1_wb3/output_20260718T134902/cursor.hooks.workspaceId-8c2fbc6e13f4f49039de1904ef15d72e.log

101 failures

2026-07-19 07:38 → 11:31

Failure example

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

Related context:

  • Hook config: ~/.cursor/hooks.json → preToolUse / matcher Shell → hooks/mise-shell.sh (5s timeout)
  • Also noisy but separate: Failed to parse project hooks configuration when a workspace has no .cursor/hooks.json (benign)
  • Renderer: only $updateShellExecCapabilities info lines — no stack traces for the failure
  • Not in: main.log
  • Contrast: in this logs workspace (wb11), the same hook often succeeds (exit code: 0)

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.”

It’s looking quite a lot like this issue over here.

Could you share the same logs?