Error on startup, seems to be related to dump_bash_state

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

After upgrading to version 1.6 (I’m not sure exactly when this issue first appeare, I tried a few previous versions from GitHub - worryzyy/awesome-cursor-download: Cursor历史版本下载、Cursor下载链接追踪器,Cursor beta版本、 Cursor下载中心 and it seems the problem exists in all of them), I got the following error every time I launch cursor:

/bin/bash: line 33: warning: here-document at line 5 delimited by end-of-file (wanted `CURSOR_SNAP_EOF_%sn \"$var_name\" \"$var_name\"
      base64 -w 0 <<<\"$content\"
      printf nCURSOR_SNAP_EOF_%sn \"$var_name\"
      printf ')
/bin/bash: -c: line 1: unexpected EOF while looking for matching `)'

Steps to Reproduce

launch cursor

Screenshots / Screen Recordings

Operating System

Windows 10/11

Current Cursor Version (Menu → About Cursor → Copy)

Version: 1.6.26 (system setup)
VSCode Version: 1.99.3
Commit: 6af2d906e8ca91654dd7c4224a73ef17900ad730
Date: 2025-09-16T17:12:31.697Z
Electron: 34.5.8
Chromium: 132.0.6834.210
Node.js: 20.19.1
V8: 13.2.152.41-electron.0
OS: Windows_NT x64 10.0.19045

Additional Information

I used promon to check the processes when cursor starts. Here is the problematic command. I saved it directly as a .sh file and ran it with bash, and encountered the same issue.

bash -lc "#!/usr/bin/env bash

# Usage:
#   source dump_bash_state.bash
#   dump_bash_state OUTPUT_FILE
# Or execute directly (captures a subshell's state):
#   ./dump_bash_state.bash OUTPUT_FILE

dump_bash_state() {
  set -euo pipefail

  # Require base64 for safe encoding of emitted sections
  if ! command -v base64 >/dev/null 2>&1; then
    echo \"Error: base64 command is required\" >&2
    return 1
  fi

  # Helper to log timing, only if DUMP_BASH_STATE_TIMING is set
  if [[ -n \"${DUMP_BASH_STATE_TIMING:-}\" ]]; then
    # Timing setup
    if [[ \"${BASH_VERSION%%.*}\" -ge 5 ]]; then
      # Use EPOCHREALTIME if available (bash 5+)
      local start_time=${EPOCHREALTIME}
      local step_start=${EPOCHREALTIME}
      _log_timing() {
        local step_name=\"$1\"
        local now=${EPOCHREALTIME}
        local step_duration=$(awk \"BEGIN {printf \"%.3f\", $now - $step_start}\")
        local total_duration=$(awk \"BEGIN {printf \"%.3f\", $now - $start_time}\")
        printf \"[TIMING] %-20s: %6.3fs (total: %6.3fs)
\" \"$step_name\" \"$step_duration\" \"$total_duration\" >&2
        step_start=$now
      }
    else
      # Fallback for older bash versions
      local start_time=$(date +%s.%N)
      local step_start=$(date +%s.%N)
      _log_timing() {
        local step_name=\"$1\"
        local now=$(date +%s.%N)
        local step_duration=$(awk \"BEGIN {printf \"%.3f\", $now - $step_start}\")
        local total_duration=$(awk \"BEGIN {printf \"%.3f\", $now - $start_time}\")
        printf \"[TIMING] %-20s: %6.3fs (total: %6.3fs)
\" \"$step_name\" \"$step_duration\" \"$total_duration\" >&2
        step_start=$now
      }
    fi
  else
    _log_timing() { :; }
  fi

  # Helper to append a line to output file
  _emit() {
    printf '%s\n' \"$1\"
  }

  # Helper to safely encode and emit unsafe values
  _emit_encoded() {
    local content=\"$1\"
    local var_name=\"$2\"
    if [[ -n \"$content\" ]]; then
      # Use here-document to avoid argument list length limits entirely
      printf 'cursor_snap_%s=$(base64 -d <<'''CURSOR_SNAP_EOF_%s'''\n' \"$var_name\" \"$var_name\"
      base64 -w 0 <<<\"$content\"
      printf '\nCURSOR_SNAP_EOF_%s\n' \"$var_name\"
      printf ')\n'
      printf 'eval \"$cursor_snap_%s\"\n' \"$var_name\"
    fi
  }

  # Start fresh
  _log_timing \"file_init\"

  # Working directory
  _emit \"$PWD\"
  _log_timing \"working_dir\"

  # Environment variables (export statements)
  local env_vars
  env_vars=$(export -p 2>/dev/null || true)
  _emit_encoded \"$env_vars\" \"ENV_VARS_B64\"
  _log_timing \"environment\"

  # Functions: capture all functions
  local all_functions
  all_functions=$(declare -f 2>/dev/null || true)
  _emit_encoded \"$all_functions\" \"FUNCTIONS_B64\"
  _log_timing \"functions\"


  # Done
  _log_timing \"finalize\"
}
 dump_bash_state >&4"

Does this stop you from using Cursor

No - Cursor works, but with this issue

2 Likes

I got the same issue.

Cursor Version:

Version: 1.6.26 (user setup)
VSCode Version: 1.99.3
Commit: 6af2d906e8ca91654dd7c4224a73ef17900ad730
Date: 2025-09-16T17:12:31.697Z
Electron: 34.5.8
Chromium: 132.0.6834.210
Node.js: 20.19.1
V8: 13.2.152.41-electron.0
OS: Windows_NT x64 10.0.26100

Error from bash startup:

/bin/bash: line 66: warning: command substitution: 1 unterminated here-document
/bin/bash: line 94: warning: here-document at line 66 delimited by end-of-file (wanted 'CURSOR_SNAP_EOF_%sn “$var_name
“$var_name”
base64 -w 0 <<< “$content”
printf nCURSOR_SNAP_EOF_%sn “$var_name”
printf ')
/bin/bash: -c: line 1: unexpected EOF while looking for matching ‘”’

same issue. multiple windows terminals open up when I open or reload cursor.

This should already be fixed. Please update to v1.6.35 and let me know if the issue persists.

I still have an issue here, but the error message is different now.

The new command is:

This command use C:\Windows\system32\bash.exe, but running it with bash in Linux will get the same issue.

# save to test.sh and run on linux
bash -O extglob -ilc "#!/usr/bin/env bash

# Usage:
#   source dump_bash_state.bash
#   dump_bash_state OUTPUT_FILE
# Or execute directly (captures a subshell's state):
#   ./dump_bash_state.bash OUTPUT_FILE

dump_bash_state() {
  set -euo pipefail

  # Require base64 for safe encoding of emitted sections
  if ! command -v base64 >/dev/null 2>&1; then
    echo \"Error: base64 command is required\" >&2
    return 1
  fi

  # Helper to log timing, only if DUMP_BASH_STATE_TIMING is set
  if [[ -n \"${DUMP_BASH_STATE_TIMING:-}\" ]]; then
    # Timing setup
    if [[ \"${BASH_VERSION%%.*}\" -ge 5 ]]; then
      # Use EPOCHREALTIME if available (bash 5+)
      local start_time=${EPOCHREALTIME}
      local step_start=${EPOCHREALTIME}
      _log_timing() {
        local step_name=\"$1\"
        local now=${EPOCHREALTIME}
        local step_duration=$(command awk \"BEGIN {printf \"%.3f\", $now - $step_start}\")
        local total_duration=$(command awk \"BEGIN {printf \"%.3f\", $now - $start_time}\")
        builtin printf \"[TIMING] %-20s: %6.3fs (total: %6.3fs)
\" \"$step_name\" \"$step_duration\" \"$total_duration\" >&2
        step_start=$now
      }
    else
      # Fallback for older bash versions
      local start_time=$(command date +%s.%N)
      local step_start=$(command date +%s.%N)
      _log_timing() {
        local step_name=\"$1\"
        local now=$(command date +%s.%N)
        local step_duration=$(command awk \"BEGIN {printf \"%.3f\", $now - $step_start}\")
        local total_duration=$(command awk \"BEGIN {printf \"%.3f\", $now - $start_time}\")
        builtin printf \"[TIMING] %-20s: %6.3fs (total: %6.3fs)
\" \"$step_name\" \"$step_duration\" \"$total_duration\" >&2
        step_start=$now
      }
    fi
  else
    _log_timing() { :; }
  fi

  # Helper to append a line to output file
  _emit() {
    builtin printf '%s
' \"$1\"
  }

  # Helper to safely encode and emit unsafe values
  _emit_encoded() {
    local content=\"$1\"
    local var_name=\"$2\"
    if [[ -n \"$content\" ]]; then
      builtin printf 'cursor_snap_%s=$(command base64 -d <<'''CURSOR_SNAP_EOF_%s'''
' \"$var_name\" \"$var_name\"
      command base64 <<<\"$content\" | command tr -d '
'
      builtin printf '
CURSOR_SNAP_EOF_%s
' \"$var_name\"
      builtin printf ')
'
      builtin printf 'eval \"$cursor_snap_%s\"
' \"$var_name\"
    fi
  }

  # Start fresh
  _log_timing \"file_init\"

  # Working directory
  _emit \"$PWD\"
  _log_timing \"working_dir\"

  # Environment variables (export statements)
  local env_vars
  env_vars=$(builtin export -p 2>/dev/null || true)
  _emit_encoded \"$env_vars\" \"ENV_VARS_B64\"
  _log_timing \"environment\"

  # POSIX shell options (replayable as set +/-o lines)
  local posix_opts
  posix_opts=$(builtin shopt -po 2>/dev/null || true)
  _emit_encoded \"$posix_opts\" \"POSIX_OPTS_B64\"
  _log_timing \"posix_options\"

  # Bash shopt options (replayable as shopt -s/-u lines)
  local bash_opts
  bash_opts=$(builtin shopt -p 2>/dev/null || true)
  _emit_encoded \"$bash_opts\" \"BASH_OPTS_B64\"
  _log_timing \"bash_options\"

  # Aliases
  local aliases
  aliases=$(builtin alias -p 2>/dev/null || true)
  _emit_encoded \"$aliases\" \"ALIASES_B64\"
  _log_timing \"aliases\"

  # Functions: capture all functions
  local all_functions
  all_functions=$(builtin declare -f 2>/dev/null || true)
  _emit_encoded \"$all_functions\" \"FUNCTIONS_B64\"
  _log_timing \"functions\"


  # Done
  _log_timing \"finalize\"
}
 builtin printf '__CURSOR_STATE_MARKER__\n'; dump_bash_state"

Output:

awk: cmd. line:1: "BEGIN
awk: cmd. line:1: ^ unterminated string
awk: cmd. line:1: "BEGIN
awk: cmd. line:1: ^ unterminated string
awk: cmd. line:1: "BEGIN
awk: cmd. line:1: ^ unterminated string
awk: cmd. line:1: "BEGIN
awk: cmd. line:1: ^ unterminated string
base64: invalid input
test.sh: line 9: $' \\"$var_name\\"\r\n      builtin printf ': command not found
: command not found
: command not found
bash: syntax error near unexpected token `$'{\r''

Cursor Version:

Version: 1.6.35 (system setup)
VSCode Version: 1.99.3
Commit: b753cece5c67c47cb5637199a5a5de2b7100c180
Date: 2025-09-19T17:39:38.846Z
Electron: 34.5.8
Chromium: 132.0.6834.210
Node.js: 20.19.1
V8: 13.2.152.41-electron.0
OS: Windows_NT x64 10.0.19045

Hi all, this issue should be fixed in version 1.6.42. Could you try upgrading?

1 Like

I also had this issue in 1.6.35 and can confirm that it was fixed in 1.6.42, thanks :ok_hand:

1 Like

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