Skip to content

Instantly share code, notes, and snippets.

@CS-Martin
Last active August 1, 2024 04:16
Show Gist options
  • Save CS-Martin/68e6c5083f7437cfc8f9d35d6e8bf6c9 to your computer and use it in GitHub Desktop.
Save CS-Martin/68e6c5083f7437cfc8f9d35d6e8bf6c9 to your computer and use it in GitHub Desktop.
Cursor IDE command 'cursor .' bash not working in Windows 10/11

Cursor IDE command 'cursor .' bash not working in Windows 10/11

Short Description

When using cursor . in git-bash to open Cursor IDE shows an error:

/c/Users/<username>/AppData/Local/Programs/cursor/resources/app/bin/cursor: line 62: /c/Users/<username>/AppData/Local/Programs/cursor/resources/app/bin/../cursor: No such file or directory

Please note that this is a temporary fix. This solution is going to be overwritten when you update Cursor IDE.

Steps

  1. Find the path of your cursor

    • For Windows git-bash

      $where cursor
      
      Output:
      C:\Users\<username>\AppData\Local\Programs\cursor\resources\app\bin\cursor
      C:\Users\<username>\AppData\Local\Programs\cursor\resources\app\bin\cursor.cmd
  2. Go to directory C:\Users\<username>\AppData\Local\Programs\cursor\resources\app\bin\cursor and open cursor file using a text editor

  3. The content of cursor file should be something like this

    #!/usr/bin/env sh
    #
    # Copyright (c) Microsoft Corporation. All rights reserved.
    # Licensed under the MIT License. See License.txt in the project root for license information.
    
    ....other codes
    
    if [ ! -L "$0" ]; then
      # if path is not a symlink, find relatively
      VSCODE_PATH="$(dirname "$0")/.."
    else
      if command -v readlink >/dev/null; then
        # if readlink exists, follow the symlink and find relatively
        VSCODE_PATH="$(dirname "$(readlink -f "$0")")/.."
      else
        # else use the standard install location
        VSCODE_PATH="/usr/share/cursor"
      fi
    fi
    
    ELECTRON="$VSCODE_PATH/cursor"
    CLI="$VSCODE_PATH/resources/app/out/cli.js"
    ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@"
    exit $?
    
  4. It appears that the files in the bin directory need to be moved to a higher directory. Thus, we need to the script:

    if [ ! -L "$0" ]; then
      # if path is not a symlink, find relatively
      VSCODE_PATH="$(dirname "$0")/../../.." # <--- Change default to this
    else
      if command -v readlink >/dev/null; then
        # if readlink exists, follow the symlink and find relatively
        VSCODE_PATH="$(dirname "$(readlink -f "$0")")/.."
      else
        # else use the standard install location
        VSCODE_PATH="/usr/share/cursor"
      fi
    fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment