Where does the bug appear (feature/product)?
Cursor IDE
Describe the Bug
Summary
When executing bash commands in Cursor on Windows with Git Bash, if the PATH environment variable contains directories with parentheses (e.g., /c/Program Files (x86)/), the dump_bash_state function generates output that causes a bash syntax error when evaluated.
Environment
- OS: Windows 10/11 (build 26200)
- Shell: Git Bash (via Cursor integrated terminal)
- Cursor Version: Latest (check your version)
- Issue: Bash syntax error when executing commands
Error Message
--: eval: line 3: syntax error near unexpected token `(`
--: eval: line 3: `PATH=/mingw64/bin:/usr/bin:/c/Users/lucam/bin:/c/Program Files/Microsoft SDKs/Azure/CLI2/wbin:/c/Program Files (x86)/Razer Chroma SDK/bin:...`
Root Cause
The dump_bash_state function in Cursor’s extensionHostProcess.js emits environment variables (specifically PATH) without proper quoting. When bash tries to evaluate the output with eval, parentheses () are interpreted as subshell syntax, causing a syntax error.
Technical Details
-
Location:
C:\Program Files\cursor\resources\app\out\vs\workbench\api\node\extensionHostProcess.js- Function
dump_bash_stateis defined around line 402-510 - The function uses
export -pto capture environment variables (line 479) - Variables are encoded in base64, but when decoded and evaluated, PATH is emitted without quotes
- Function
-
Problematic Code Flow:
// Line 479: Captures environment variables env_vars=$(builtin export -p 2>/dev/null || true) _emit_encoded "$env_vars" "ENV_VARS_B64"When the encoded content is decoded and evaluated, it produces:
PATH=/c/Program Files (x86)/Razer Chroma SDK/bin:...Instead of:
PATH="/c/Program Files (x86)/Razer Chroma SDK/bin:..." -
Why it fails: Bash interprets
(x86)as an attempt to create a subshell, but there’s no command to execute, resulting in a syntax error.
Steps to Reproduce
- Have a Windows system with Git Bash installed
- Ensure PATH contains directories with parentheses (common on Windows, e.g.,
/c/Program Files (x86)/) - Open Cursor
- Open integrated terminal (Git Bash)
- Execute any bash command (e.g.,
ls,pwd,echo "test") - Observe the syntax error after command execution
Expected Behavior
Commands should execute successfully without syntax errors, regardless of PATH content.
Actual Behavior
Every bash command fails with a syntax error because Cursor’s dump_bash_state function is called after each command and produces invalid bash syntax.
Impact
- Severity: High - Prevents normal use of bash terminal in Cursor on Windows
- Frequency: 100% - Occurs on every bash command execution
- Workaround: None - Workarounds in
.bashrcdon’t work because Cursor injects the function directly into generated bash scripts, bypassing.bashrc
Attempted Workarounds (Not Working)
We attempted several workarounds in .bashrc:
- Function stub: Define a silent stub function
- PROMPT_COMMAND: Override function at every prompt
- readonly: Make function readonly to prevent overwriting
- trap DEBUG: Intercept function calls
None of these work because Cursor injects the complete function definition directly into the bash script it generates for command execution, bypassing .bashrc entirely.
Suggested Fix
Cursor should ensure that all environment variables emitted by dump_bash_state are properly quoted, especially when they contain special characters like:
- Parentheses
() - Spaces
- Other special bash characters
Recommended Code Change
In extensionHostProcess.js, the _emit_encoded function should ensure that when environment variables are decoded and emitted, they are properly quoted. Alternatively, the export -p output should be processed to quote values containing special characters.
Example fix:
# Instead of emitting:
PATH=/c/Program Files (x86)/...
# Emit:
PATH="/c/Program Files (x86)/..."
Or ensure that the base64 encoding/decoding process preserves quotes from export -p output.
Additional Information
- The function
dump_bash_stateis called after every command execution - The error occurs when Cursor tries to evaluate the output of
dump_bash_stateto restore shell state - The issue is specific to Windows paths with parentheses, which are very common on Windows systems
- The bug affects all users on Windows with standard PATH configurations
Files for Reference
C:\Program Files\cursor\resources\app\out\vs\workbench\api\node\extensionHostProcess.js(lines 402-510)- Error occurs when evaluating the output of
dump_bash_statefunction
Contact
Please fix this issue as it severely impacts the usability of Cursor’s integrated terminal on Windows systems.
Note: This bug report was generated after extensive debugging attempts. All workarounds in .bashrc fail because Cursor bypasses .bashrc when generating bash scripts for command execution.
Steps to Reproduce
Prerequisites
- Windows 10/11 system with Git Bash installed
- PATH environment variable containing directories with parentheses (very common on Windows)
- Typical examples:
/c/Program Files (x86)/,/c/Program Files (x86)/Microsoft SDKs/, etc. - Most Windows systems have these by default
- Typical examples:
Reproduction Steps
-
Open Cursor on Windows
-
Open integrated terminal (should default to Git Bash on Windows)
-
Execute any simple bash command, for example:
echo "Hello World"or
lsor
pwd -
Observe the error: After the command executes (it may succeed), you will see:
--: eval: line 3: syntax error near unexpected token `(` --: eval: line 3: `PATH=/mingw64/bin:/usr/bin:/c/Users/.../bin:/c/Program Files (x86)/...` -
Verify: The error occurs on EVERY bash command execution, not just the first one.
Detailed Example
$ echo "test"
test
--: eval: line 3: syntax error near unexpected token `(`
--: eval: line 3: `PATH=/mingw64/bin:/usr/bin:/c/Users/lucam/bin:/c/Program Files/Microsoft SDKs/Azure/CLI2/wbin:/c/Program Files (x86)/Razer Chroma SDK/bin:...`
The command itself (echo "test") executes successfully and produces output, but immediately after, Cursor calls dump_bash_state which fails.
Verification
To verify your PATH contains problematic directories, run:
echo $PATH | grep -o '/[^:]*([^:]*[^:]*'
This will show paths containing parentheses.
Expected Behavior
Expected Behavior
- Commands should execute successfully without any syntax errors
- No error messages should appear after command execution
- The integrated terminal should work normally just like a standalone Git Bash terminal
- PATH with parentheses should be handled correctly - Cursor should properly quote environment variables when emitting them, regardless of their content
- Shell state should be preserved without errors - the
dump_bash_statefunction should work correctly even with complex PATH values
Example of Expected Output
$ echo "test"
test
$ ls
file1.txt file2.txt
$ pwd
/c/Users/lucam/Documents/PendoloView
No errors should appear after any command.
Operating System
Windows 10/11
Current Cursor Version (Menu → About Cursor → Copy)
Version: 2.1.42 (user setup)
VSCode Version: 1.105.1
Commit: 2e353c5f5b30150ff7b874dee5a87660693d9de0
Date: 2025-12-01T02:18:26.377Z
Electron: 37.7.0
Chromium: 138.0.7204.251
Node.js: 22.20.0
V8: 13.8.258.32-electron.0
OS: Windows_NT x64 10.0.26200
For AI issues: which model did you use?
I userd Composer1 to diagnose the problem.
Additional Information
I also reinstalled cursor but no changese occurred in the behaviour.
Does this stop you from using Cursor
Yes - Cursor is unusable