Cursor terminal hangs after extended use

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

Terminal commands consistently start hanging after extended Cursor sessions, requiring IDE restart to resolve.

Steps to Reproduce

  1. Use Cursor for an extended session (typically several hours or overnight)
  2. Attempt to run any terminal command through Cursor’s integrated terminal
  3. Commands hang indefinitely
  4. Parse error visible when opening terminal panel: /private/var/folders/.../T/rtkendall-cursor-zsh/.zshrc:51: parse error near 'unset'

Expected Behavior

Terminal commands should execute normally regardless of session length.

Operating System

MacOS

Current Cursor Version (Menu → About Cursor → Copy)

Version: 1.7.44 (Universal)
VSCode Version: 1.99.3
Commit: 9d178a4■■■89981b62546448bb32920a8219a5d0
Date: 2025-10-10T15:43:37.500Z
Electron: 34.5.8
Chromium: 132.0.6834.210
Node.js: 20.19.1
V8: 13.2.152.41-electron.0
OS: Darwin arm64 24.6.0

For AI issues: which model did you use?

Sonnet 4

Additional Information

The AI agent diagnosed the problem and found the root cause:

Root Cause Discovered

Corruption in Cursor’s temporary shell configuration file:
/private/var/folders/.../T/rtkendall-cursor-zsh/.zshrc

Technical Details

The corruption occurs in Cursor’s environment variable management code:

if [ -n "${VSCODE_ENV_REPLACE:-}" ]; then
    IFS=':' read -rA ADDR <<< "$VSCODE_ENV_REPLACE"
    for ITEM in "${ADDR[@]}"; do
        VARNAME="$(echo ${ITEM%%=*})"
        export $VARNAME="$(echo -e ${ITEM#*=})"
    done
    unset VSCODE_ENV_REPLACE  # <-- Parse error occurs around here
fi

Diagnostic Script Created

I’ve created a script to detect this corruption:

#!/bin/bash
CURSOR_TEMP_DIR="/private/var/folders/.../T/rtkendall-cursor-zsh"
ZSHRC_FILE="$CURSOR_TEMP_DIR/.zshrc"

if [ ! -f "$ZSHRC_FILE" ]; then
    echo "✅ No Cursor temp .zshrc found"
    exit 0
fi

if ! zsh -n "$ZSHRC_FILE" 2>/dev/null; then
    echo "🚨 Corrupted Cursor .zshrc detected!"
    echo "📁 Location: $ZSHRC_FILE"
    zsh -n "$ZSHRC_FILE"
    exit 1
else
    echo "✅ Cursor temp .zshrc is healthy"
fi

Why This Looks Like a Cursor Bug

  1. Cursor-owned files getting corrupted: The corruption happens in /private/var/folders/.../T/rtkendall-cursor-zsh/.zshrc - a file that Cursor creates and manages

  2. Consistent pattern: Happens reliably after extended Cursor sessions across multiple days

  3. Always fixed by restart: Restarting Cursor regenerates clean temp files, which shouldn’t be necessary if the files were stable

  4. Environment variable management code: The corruption specifically affects VSCODE_ENV_* variables and unset commands that Cursor uses for shell integration

What’s Likely Happening

Cursor probably has a bug in how it:

  1. Updates environment variables during long sessions
  2. Writes to its temporary shell configuration files
  3. Manages shell state over time

The temp .zshrc should remain stable once created, but something is corrupting it progressively.

Impact

This significantly disrupts development workflow as terminal commands become unusable, requiring frequent IDE restarts.

Additional Notes

  • The temporary directory path includes the username, suggesting per-user temp files
  • Corruption builds up gradually over extended sessions
  • Only affects Cursor’s managed shell files, not user’s actual .zshrc

Does this stop you from using Cursor

No - Cursor works, but with this issue

Hey, thanks for the report. The parse error in the temp .zshrc file points to an issue with how Cursor handles shell integration files during long sessions.

It looks like a regression or a related issue to the zsh bug fixed in v1.7.28, but you’re already on v1.7.44.

I’ll pass this to the team. A few quick questions to help reproduce:

  1. Roughly how long before the terminal starts hanging (e.g., 4+ hours, overnight, varies)?
  2. Is it tied to specific activities in Cursor, or just time‑based?
  3. When you run your diagnostic script in the “hang” state, does it always show the same corruption pattern at line 51?

Your diagnostic script is super helpful, thanks for sharing it.

I put these questions to the ai agent and this is the response, which seems accurate to me:

1. Timing Pattern

Answer: Roughly 4-8 hours of active Cursor usage, but varies. Sometimes overnight if Cursor is left open, sometimes during intense coding sessions. It’s not strictly time-based - seems related to cumulative shell operations.

Technical insight: The corruption appears to build up over multiple terminal operations rather than happening at a specific time interval.

2. Activity Correlation

Answer: Appears tied to cumulative terminal activity rather than specific actions. More frequent with:

  • Heavy git operations (our pre-push hooks, frequent commits)

  • Running node scripts repeatedly

  • Multiple terminal sessions

  • Long coding sessions with lots of command execution

Technical insight: The corruption seems to accumulate in Cursor’s environment variable management code, suggesting it’s related to how Cursor updates VSCODE_ENV_* variables over time.

3. Corruption Pattern Consistency

Answer: Yes, always the same location and pattern:

  • File: /private/var/folders/…/T/rtkendall-cursor-zsh/.zshrc

  • Line: Around line 51 (varies slightly)

  • Error: parse error near ‘unset’

  • Context: Always in the VSCODE_ENV_REPLACE management block

Code that gets corrupted:

if [ -n “${VSCODE_ENV_REPLACE:-}” ]; then

\# ... variable processing ...

unset VSCODE_ENV_REPLACE  # ← This area gets corrupted

fi

Additional Technical Details to Include:

Diagnostic Script Created:

# We created this to detect the issue

./scripts/fix-cursor-shell.sh

# Tests: zsh -n “$CURSOR_TEMP_DIR/.zshrc”

Reproduction Environment:

  • macOS 14.6.0 (darwin 24.6.0)

  • Heavy git hook usage (pre-push scripts)

  • Multiple node.js script executions

  • Shell: /bin/zsh

Workaround:

  • Restart Cursor (regenerates clean temp files)

  • Or manually delete the temp directory

Root Cause Hypothesis:

Cursor’s shell integration code has a race condition or accumulation bug in how it manages environment variable updates to the temporary .zshrc file over extended usage.

1 Like

More data about this issue and the corrupted file:

Diagnostic script shows file is “healthy” when read statically

  • But Cursor terminal shows “parse error near ‘unset’” when executing
  • Suggests race condition in concurrent file read/write operations
  • Always happens around line 51 (environment variable section)
  • Only solution is full application restart

Updated diagnostics script:

```

#!/bin/bash

# Fix Cursor Shell Corruption

# This script detects and fixes corrupted Cursor temporary .zshrc files

echo “:magnifying_glass_tilted_left: Searching for Cursor temp .zshrc files…”

# Find all cursor-zsh directories dynamically

CURSOR_DIRS=$(find /private/var/folders -name “*cursor-zsh” 2>/dev/null)

if [ -z “$CURSOR_DIRS” ]; then

echo "✅ No Cursor temp directories found (normal if Cursor not running)"

exit 0

fi

CORRUPTED_COUNT=0

HEALTHY_COUNT=0

for CURSOR_TEMP_DIR in $CURSOR_DIRS; do

ZSHRC_FILE="$CURSOR_TEMP_DIR/.zshrc"

if [ ! -f “$ZSHRC_FILE” ]; then

continue

fi

echo "📁 Checking: $ZSHRC_FILE"

# Test if the .zshrc file has syntax errors

if ! zsh -n “$ZSHRC_FILE” 2>/tmp/cursor_error.log; then

    echo "🚨 CORRUPTED Cursor .zshrc detected!"

    echo "📁 Location: $ZSHRC_FILE"

# Show the error

    echo "❌ Syntax check output:"

    cat /tmp/cursor_error.log

# Show problematic lines around line 51 (common error location)

    echo ""

    echo "🔍 Content around line 51:"

    sed -n '45,55p' "$ZSHRC_FILE" 2>/dev/null | nl -ba -v45 || echo "Could not read file content"

    echo ""

    echo "💡 Solution: Restart Cursor to regenerate clean temp files"

    echo "   Or run: rm -rf '$CURSOR_TEMP_DIR' (Cursor will recreate it)"

    CORRUPTED_COUNT=$((CORRUPTED_COUNT + 1))

else

    echo "✅ Healthy"

    HEALTHY_COUNT=$((HEALTHY_COUNT + 1))

fi

echo "---"

done

echo “”

echo “:bar_chart: Summary: $HEALTHY_COUNT healthy, $CORRUPTED_COUNT corrupted”

if [ $CORRUPTED_COUNT -gt 0 ]; then

exit 1

else

exit 0

fi
```

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

As I’m running programs and developing the terminal randomly dies on me and doesn’t start working again unless I reset my laptop.

Steps to Reproduce

So far I’ve just been using my terminal alongside the ask mode, multiple agent windows, I believe that may be the cause, no issues until I start using it.

Expected Behavior

the terminal, just disconnects and when I make another it just loads forever.

Operating System

MacOS

Current Cursor Version (Menu → About Cursor → Copy)

Version: 1.7.33
VSCode Version: 1.99.3
Commit: a84f941711ad680a635c8a3456002833186c4840
Date: 2025-10-03T03:28:06.574Z (1 wk ago)

Does this stop you from using Cursor

No - Cursor works, but with this issue

This topic was automatically closed 22 days after the last reply. New replies are no longer allowed.