cursor
cursor copied to clipboard
Bug: Cursor is not launching through `cusrsor .` or `code .` command in WSL2 Distro ubuntu.
I am trying to launch cursor through WSL ubuntu but there is some error related to .cursor-server file
screenshots:
Have the same issue on my end.
Yep, this is expected atm. We will look into fixing as soon as we can.
@truell20 please close this issue as soon as it is fixed so that I will be able to use cursor again with WSL
Just to add to this issue, I see a different sort of error when attempting to run cursor in Ubuntu on WSL2:
ursor
To use Cursor with the Windows Subsystem for Linux, please install Cursor in Windows and uninstall the Linux version in WSL. You can then use the `cursor` command in a WSL terminal just as you would in a normal command prompt.
Do you want to continue anyway? [y/N] y
To no longer see this prompt, start Cursor with the environment variable DONT_PROMPT_WSL_INSTALL defined.
/mnt/c/Users/taoha/AppData/Local/Programs/cursor/resources/app/bin/cursor: 62: /mnt/c/Users/taoha/AppData/Local/Programs/cursor/resources/app/bin/../cursor: not found
Just to add to this issue, I see a different sort of error when attempting to run
cursorin Ubuntu on WSL2:ursor To use Cursor with the Windows Subsystem for Linux, please install Cursor in Windows and uninstall the Linux version in WSL. You can then use the `cursor` command in a WSL terminal just as you would in a normal command prompt. Do you want to continue anyway? [y/N] y To no longer see this prompt, start Cursor with the environment variable DONT_PROMPT_WSL_INSTALL defined. /mnt/c/Users/taoha/AppData/Local/Programs/cursor/resources/app/bin/cursor: 62: /mnt/c/Users/taoha/AppData/Local/Programs/cursor/resources/app/bin/../cursor: not found
Same thing here! Also noticed it broke my code . command as well ... luckily I can just open Cursor and go on my way, watching this for updates 🫡
Any updates on this? Still broken for me
It's unbelievable this is still broken after so many months, and the fix is rather simple. Sadly Cursor is not open source... but here's a quick workaround based on VS Code's current launcher from WSL:
[!CAUTION] This will most likely break after Cursor gets an update. Hopefully they'll fix this in the next update, but if not these tweaks may need to be done again after every update.
[!NOTE] You should install the WSL Extension before attempting these steps
[!IMPORTANT] I opened a WSL folder at least once before doing these steps. Doing so installed Cursor's WSL Server in
~/.cursor-server/bin. I'm not sure if this altered VS Code script would trigger that too if you directly runcursorwithout the WSL Server installed.
- Open the
cursorlinux script- Most likely located at
C:\Users\<your user>\AppData\Local\Programs\cursor\resources\app\bin\ - If you've installed the
cursorcommand you can also:- Use
whichin WSL:$ which cursor /mnt/c/Users/lesmo/AppData/Local/Programs/cursor/resources/app/bin/cursor - Use
wherein Windows' Command Prompt:> where cursor c:\Users\lesmo\AppData\Local\Programs\cursor\resources\app\bin\cursor c:\Users\lesmo\AppData\Local\Programs\cursor\resources\app\bin\cursor.cmd - Use
(Get-Command cursor).Sourcein PowerShell :> (Get-Command code).Source C:\Users\lesmo\AppData\Local\Programs\Microsoft VS Code\bin\code.cmd
- Use
- Most likely located at
- Copy the
codelinux script contents into thecursorone- Most likely located at
C:\Users\<your user>\AppData\Local\Programs\Microsoft VS Code\bin\
- Most likely located at
- Patch the script with:
- Cursor values for the variables:
COMMITshould have the value of the binary under~/.cursor-server/bin, which for me right now is56becd74fc3058ee97a0b2496d8ae7ad2c2fcb10APP_NAMEshould be"cursor"NAMEshould be"Cursor"SERVERDATAFOLDERshould be".cursor-server"VSCODE_PATHshould be"$(dirname "$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")")"- Paths slightly differ from VS Code, so this extra
dirnamecalls are necessary)
- Paths slightly differ from VS Code, so this extra
- Fix the semi-invalid output from the call to Cursor as CLI in line 47
- The
cat /tmp/remote-wsl-loc.txtexpects to only output a path, but it outputs 2 lines that breaks the script. To fix this, we forcibly get only the 2nd line:WSL_EXT_WLOC=$(cat /tmp/remote-wsl-loc.txt | head -2 | tail -1)
- The
- Cursor values for the variables:
Cursor will now be correctly launched by whatever WSL instance invokes it:
https://github.com/getcursor/cursor/assets/2228196/f3f200c8-9325-4b49-979d-49302985e58e
This is my current cursor file contents:
#!/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.
if [ "$VSCODE_WSL_DEBUG_INFO" = true ]; then
set -x
fi
COMMIT="56becd74fc3058ee97a0b2496d8ae7ad2c2fcb10"
APP_NAME="cursor"
QUALITY="stable"
NAME="Cursor"
SERVERDATAFOLDER=".cursor-server"
VSCODE_PATH="$(dirname "$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")")"
ELECTRON="$VSCODE_PATH/$NAME.exe"
IN_WSL=false
if [ -n "$WSL_DISTRO_NAME" ]; then
# $WSL_DISTRO_NAME is available since WSL builds 18362, also for WSL2
IN_WSL=true
else
WSL_BUILD=$(uname -r | sed -E 's/^[0-9.]+-([0-9]+)-Microsoft.*|.*/\1/')
if [ -n "$WSL_BUILD" ]; then
if [ "$WSL_BUILD" -ge 17063 ]; then
# WSLPATH is available since WSL build 17046
# WSLENV is available since WSL build 17063
IN_WSL=true
else
# If running under older WSL, don't pass cli.js to Electron as
# environment vars cannot be transferred from WSL to Windows
# See: https://github.com/microsoft/BashOnWindows/issues/1363
# https://github.com/microsoft/BashOnWindows/issues/1494
"$ELECTRON" "$@"
exit $?
fi
fi
fi
if [ $IN_WSL = true ]; then
export WSLENV="ELECTRON_RUN_AS_NODE/w:$WSLENV"
CLI=$(wslpath -m "$VSCODE_PATH/resources/app/out/cli.js")
# use the Remote WSL extension if installed
WSL_EXT_ID="ms-vscode-remote.remote-wsl"
ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" --locate-extension $WSL_EXT_ID >/tmp/remote-wsl-loc.txt 2>/dev/null </dev/null
WSL_EXT_WLOC=$(cat /tmp/remote-wsl-loc.txt | head -2 | tail -1)
if [ -n "$WSL_EXT_WLOC" ]; then
# replace \r\n with \n in WSL_EXT_WLOC
WSL_CODE=$(wslpath -u "${WSL_EXT_WLOC%%[[:cntrl:]]}")/scripts/wslCode.sh
"$WSL_CODE" "$COMMIT" "$QUALITY" "$ELECTRON" "$APP_NAME" "$SERVERDATAFOLDER" "$@"
exit $?
fi
elif [ -x "$(command -v cygpath)" ]; then
CLI=$(cygpath -m "$VSCODE_PATH/resources/app/out/cli.js")
else
CLI="$VSCODE_PATH/resources/app/out/cli.js"
fi
ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@"
exit $?
P.S.: Cursor ppl, hire me? lol
Also see issue #807
Connecting to update.code.visualstudio.com (update.code.visualstudio.com)|13.107.213.40|:443... connected. HTTP request sent, awaiting response... 404 Not Found 2024-03-14 15:13:18 ERROR 404: Not Found.
ERROR: Failed to download https://update.code.visualstudio.com/commit:56becd74fc3058ee97a0b2496d8ae7ad2c2fcb10-1710443218/server-linux-x64/stable to /root/.cursor-server/bin/56becd74fc3058ee97a0b2496d8ae7ad2c2fcb10-1710443218-1710443598.tar.gz
i get this error
It's unbelievable this is still broken after so many months, and the fix is rather simple. Sadly Cursor is not open source... but here's a quick workaround based on VS Code's current launcher from WSL:
Caution
This will most likely break after Cursor gets an update. Hopefully they'll fix this in the next update, but if not these tweaks may need to be done again after every update.
Note
You should install the WSL Extension before attempting these steps
Important
I opened a WSL folder at least once before doing these steps. Doing so installed Cursor's WSL Server in
~/.cursor-server/bin. I'm not sure if this altered VS Code script would trigger that too if you directly runcursorwithout the WSL Server installed.
Open the
cursorlinux script
Most likely located at
C:\Users\<your user>\AppData\Local\Programs\cursor\resources\app\bin\If you've installed the
cursorcommand you can also:
- Use
whichin WSL:$ which cursor /mnt/c/Users/lesmo/AppData/Local/Programs/cursor/resources/app/bin/cursor- Use
wherein Windows' Command Prompt:> where cursor c:\Users\lesmo\AppData\Local\Programs\cursor\resources\app\bin\cursor c:\Users\lesmo\AppData\Local\Programs\cursor\resources\app\bin\cursor.cmd- Use
(Get-Command cursor).Sourcein PowerShell :> (Get-Command code).Source C:\Users\lesmo\AppData\Local\Programs\Microsoft VS Code\bin\code.cmdCopy the
codelinux script contents into thecursorone
- Most likely located at
C:\Users\<your user>\AppData\Local\Programs\Microsoft VS Code\bin\Patch the script with:
Cursor values for the variables:
COMMITshould have the value of the binary under~/.cursor-server/bin, which for me right now is56becd74fc3058ee97a0b2496d8ae7ad2c2fcb10
APP_NAMEshould be"cursor"
NAMEshould be"Cursor"
SERVERDATAFOLDERshould be".cursor-server"
VSCODE_PATHshould be"$(dirname "$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")")"
- Paths slightly differ from VS Code, so this extra
dirnamecalls are necessary)Fix the semi-invalid output from the call to Cursor as CLI in line 47
- The
cat /tmp/remote-wsl-loc.txtexpects to only output a path, but it outputs 2 lines that breaks the script. To fix this, we forcibly get only the 2nd line:WSL_EXT_WLOC=$(cat /tmp/remote-wsl-loc.txt | head -2 | tail -1)Cursor will now be correctly launched by whatever WSL instance invokes it:
20240219_014531.mp4 This is my current
cursorfile contents:#!/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. if [ "$VSCODE_WSL_DEBUG_INFO" = true ]; then set -x fi COMMIT="56becd74fc3058ee97a0b2496d8ae7ad2c2fcb10" APP_NAME="cursor" QUALITY="stable" NAME="Cursor" SERVERDATAFOLDER=".cursor-server" VSCODE_PATH="$(dirname "$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")")" ELECTRON="$VSCODE_PATH/$NAME.exe" IN_WSL=false if [ -n "$WSL_DISTRO_NAME" ]; then # $WSL_DISTRO_NAME is available since WSL builds 18362, also for WSL2 IN_WSL=true else WSL_BUILD=$(uname -r | sed -E 's/^[0-9.]+-([0-9]+)-Microsoft.*|.*/\1/') if [ -n "$WSL_BUILD" ]; then if [ "$WSL_BUILD" -ge 17063 ]; then # WSLPATH is available since WSL build 17046 # WSLENV is available since WSL build 17063 IN_WSL=true else # If running under older WSL, don't pass cli.js to Electron as # environment vars cannot be transferred from WSL to Windows # See: https://github.com/microsoft/BashOnWindows/issues/1363 # https://github.com/microsoft/BashOnWindows/issues/1494 "$ELECTRON" "$@" exit $? fi fi fi if [ $IN_WSL = true ]; then export WSLENV="ELECTRON_RUN_AS_NODE/w:$WSLENV" CLI=$(wslpath -m "$VSCODE_PATH/resources/app/out/cli.js") # use the Remote WSL extension if installed WSL_EXT_ID="ms-vscode-remote.remote-wsl" ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" --locate-extension $WSL_EXT_ID >/tmp/remote-wsl-loc.txt 2>/dev/null </dev/null WSL_EXT_WLOC=$(cat /tmp/remote-wsl-loc.txt | head -2 | tail -1) if [ -n "$WSL_EXT_WLOC" ]; then # replace \r\n with \n in WSL_EXT_WLOC WSL_CODE=$(wslpath -u "${WSL_EXT_WLOC%%[[:cntrl:]]}")/scripts/wslCode.sh "$WSL_CODE" "$COMMIT" "$QUALITY" "$ELECTRON" "$APP_NAME" "$SERVERDATAFOLDER" "$@" exit $? fi elif [ -x "$(command -v cygpath)" ]; then CLI=$(cygpath -m "$VSCODE_PATH/resources/app/out/cli.js") else CLI="$VSCODE_PATH/resources/app/out/cli.js" fi ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@" exit $?P.S.: Cursor ppl, hire me? lol
https://github.com/getcursor/cursor/issues/870#issuecomment-1951864065
I've written a small shell script that does the same thing:
#!/usr/bin/env bash
CODE_WIN_PATH="$(which code)"
CURSOR_WIN_PATH="$(which cursor)"
# overwrite cursor script with the vscode one
cp "$CODE_WIN_PATH" "$CURSOR_WIN_PATH"
# replace vscode vars and paths with cursor ones
# APP_NAME should not be replaced, since .cursor-server remote-cli still gets downloaded and extracted as "code" executable
#sed -i 's|APP_NAME="code"|APP_NAME="cursor"|' $CURSOR_WIN_PATH
sed -i 's|NAME="Code"|NAME="Cursor"|' $CURSOR_WIN_PATH
sed -i 's|SERVERDATAFOLDER=".vscode-server"|SERVERDATAFOLDER=".cursor-server"|' $CURSOR_WIN_PATH
sed -i -E 's|VSCODE_PATH=".+"|VSCODE_PATH="$(dirname "$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")")"|' $CURSOR_WIN_PATH
# fix output from the Cursor in CLI
sed -i -E 's|WSL_EXT_WLOC=(.+)|WSL_EXT_WLOC=$(tail -1 /tmp/remote-wsl-loc.txt)|' $CURSOR_WIN_PATH
I'm not 100% sure about the APP_NAME replacement, but it only worked flawlessly for me when I left it as code, since the remote-cli that gets downloaded is still named "code" - at least for me.
It's still not fixed 🤦🏻♂️
I hate to say, but uninstall Cursor is the simplest solution
You can try this:
- Open cursor, and connect to wsl
- Then run this
fixWSL.shin the wsl
#!/usr/bin/env bash
# Function to backup a file if it exists
backup_file() {
local file_path=$1
if [ -e "$file_path" ]; then
mv "$file_path" "$file_path.bak"
fi
}
# Function to safely copy a file and create a backup if it doesn't exist
safe_copy_with_backup() {
local src=$1
local dest=$2
cp "$src" "$dest"
if [ ! -e "$dest.bak" ]; then
cp "$dest" "$dest.bak"
fi
}
# Function to perform the sed replacements
perform_replacements() {
local file_path=$1
local bin_path=$2
sed -i 's|APP_NAME="code"|APP_NAME="cursor"|' "$file_path"
if [ -n "$bin_path" ]; then
local commit
commit=$(basename "$bin_path")
sed -i "s|COMMIT=\"[^\"]*\"|COMMIT=\"$commit\"|" "$file_path"
fi
sed -i 's|NAME="Code"|NAME="Cursor"|' "$file_path"
sed -i 's|SERVERDATAFOLDER=".vscode-server"|SERVERDATAFOLDER=".cursor-server"|' "$file_path"
sed -i -E 's|VSCODE_PATH=".+"|VSCODE_PATH="$(dirname "$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")")"|' "$file_path"
sed -i -E 's|WSL_EXT_WLOC=(.+)|WSL_EXT_WLOC=$(tail -1 /tmp/remote-wsl-loc.txt)|' "$file_path"
}
# Main script execution
CODE_PATH=$(which code)
if [[ "$CODE_PATH" == *"cursor"* ]]; then
backup_file "$CODE_PATH"
fi
CODE_WIN_PATH=$(which code)
CURSOR_WIN_PATH=$(which cursor)
BIN_PATH=$(ls -d ~/.cursor-server/bin/*/ 2>/dev/null | head -n 1)
safe_copy_with_backup "$CODE_WIN_PATH" "$CURSOR_WIN_PATH"
perform_replacements "$CURSOR_WIN_PATH" "$BIN_PATH"
It's unbelievable this is still broken after so many months, and the fix is rather simple. Sadly Cursor is not open source... but here's a quick workaround based on VS Code's current launcher from WSL:
Caution
This will most likely break after Cursor gets an update. Hopefully they'll fix this in the next update, but if not these tweaks may need to be done again after every update.
Note
You should install the WSL Extension before attempting these steps
Important
I opened a WSL folder at least once before doing these steps. Doing so installed Cursor's WSL Server in
~/.cursor-server/bin. I'm not sure if this altered VS Code script would trigger that too if you directly runcursorwithout the WSL Server installed.
Open the
cursorlinux script
Most likely located at
C:\Users\<your user>\AppData\Local\Programs\cursor\resources\app\bin\If you've installed the
cursorcommand you can also:
- Use
whichin WSL:$ which cursor /mnt/c/Users/lesmo/AppData/Local/Programs/cursor/resources/app/bin/cursor- Use
wherein Windows' Command Prompt:> where cursor c:\Users\lesmo\AppData\Local\Programs\cursor\resources\app\bin\cursor c:\Users\lesmo\AppData\Local\Programs\cursor\resources\app\bin\cursor.cmd- Use
(Get-Command cursor).Sourcein PowerShell :> (Get-Command code).Source C:\Users\lesmo\AppData\Local\Programs\Microsoft VS Code\bin\code.cmdCopy the
codelinux script contents into thecursorone
- Most likely located at
C:\Users\<your user>\AppData\Local\Programs\Microsoft VS Code\bin\Patch the script with:
Cursor values for the variables:
COMMITshould have the value of the binary under~/.cursor-server/bin, which for me right now is56becd74fc3058ee97a0b2496d8ae7ad2c2fcb10
APP_NAMEshould be"cursor"
NAMEshould be"Cursor"
SERVERDATAFOLDERshould be".cursor-server"
VSCODE_PATHshould be"$(dirname "$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")")"
- Paths slightly differ from VS Code, so this extra
dirnamecalls are necessary)Fix the semi-invalid output from the call to Cursor as CLI in line 47
- The
cat /tmp/remote-wsl-loc.txtexpects to only output a path, but it outputs 2 lines that breaks the script. To fix this, we forcibly get only the 2nd line:WSL_EXT_WLOC=$(cat /tmp/remote-wsl-loc.txt | head -2 | tail -1)Cursor will now be correctly launched by whatever WSL instance invokes it:
20240219_014531.mp4 This is my current
cursorfile contents:#!/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. if [ "$VSCODE_WSL_DEBUG_INFO" = true ]; then set -x fi COMMIT="56becd74fc3058ee97a0b2496d8ae7ad2c2fcb10" APP_NAME="cursor" QUALITY="stable" NAME="Cursor" SERVERDATAFOLDER=".cursor-server" VSCODE_PATH="$(dirname "$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")")" ELECTRON="$VSCODE_PATH/$NAME.exe" IN_WSL=false if [ -n "$WSL_DISTRO_NAME" ]; then # $WSL_DISTRO_NAME is available since WSL builds 18362, also for WSL2 IN_WSL=true else WSL_BUILD=$(uname -r | sed -E 's/^[0-9.]+-([0-9]+)-Microsoft.*|.*/\1/') if [ -n "$WSL_BUILD" ]; then if [ "$WSL_BUILD" -ge 17063 ]; then # WSLPATH is available since WSL build 17046 # WSLENV is available since WSL build 17063 IN_WSL=true else # If running under older WSL, don't pass cli.js to Electron as # environment vars cannot be transferred from WSL to Windows # See: https://github.com/microsoft/BashOnWindows/issues/1363 # https://github.com/microsoft/BashOnWindows/issues/1494 "$ELECTRON" "$@" exit $? fi fi fi if [ $IN_WSL = true ]; then export WSLENV="ELECTRON_RUN_AS_NODE/w:$WSLENV" CLI=$(wslpath -m "$VSCODE_PATH/resources/app/out/cli.js") # use the Remote WSL extension if installed WSL_EXT_ID="ms-vscode-remote.remote-wsl" ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" --locate-extension $WSL_EXT_ID >/tmp/remote-wsl-loc.txt 2>/dev/null </dev/null WSL_EXT_WLOC=$(cat /tmp/remote-wsl-loc.txt | head -2 | tail -1) if [ -n "$WSL_EXT_WLOC" ]; then # replace \r\n with \n in WSL_EXT_WLOC WSL_CODE=$(wslpath -u "${WSL_EXT_WLOC%%[[:cntrl:]]}")/scripts/wslCode.sh "$WSL_CODE" "$COMMIT" "$QUALITY" "$ELECTRON" "$APP_NAME" "$SERVERDATAFOLDER" "$@" exit $? fi elif [ -x "$(command -v cygpath)" ]; then CLI=$(cygpath -m "$VSCODE_PATH/resources/app/out/cli.js") else CLI="$VSCODE_PATH/resources/app/out/cli.js" fi ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@" exit $?P.S.: Cursor ppl, hire me? lol
@lesmo i think it's not a solution. each time the wsl restarted, it'll do the update and removal as following
Updating VS Code Server to version 863d2581ecda6849923a2118d93a088b0745d9d6
Removing previous installation...
Installing VS Code Server for x64 (863d2581ecda6849923a2118d93a088b0745d9d6)
Downloading: 100%
Unpacking: 100%
This guide outlines how to resolve installation problems with Cursor in your WSL environment, specifically on Arch Linux but applicable to Ubuntu as well.
Here's a breakdown of the steps:
-
Clean Uninstall:
- Uninstall Cursor through the usual method.
- Manually remove leftover folders related to Cursor in these locations:
C:/Users/<your user>/AppData/Local/Programs/C:/Users/<your user>/AppData/Local/C:/Users/<your user>/AppData/LocalLow/C:/Users/<your user>/AppData/Roaming/
- Delete folders:
C:/Users/<your user>/.cursor/C:/Users/<your user>/.cursor-tutor/
-
WSL PATH Repair:
-
Open a WSL terminal and run
printenv PATH USERto view your current PATH variables. -
Copy the output to a text editor.
-
Identify and remove any entries related to Cursor (the cursor Fix WSL install command might have added duplicates).
-
Keep the edited version in the text editor.
-
Run the following command, replacing
<copied repaired version>with the edited PATH string (use quotation marks if any path contains spaces):PATH="<copied repaired version>"
-
-
Fresh Install & Server Cleanup:
- In a WSL Terminal delete the folder
~/.cursor-server. - Reinstall Cursor, but don't click the options to add PATH variables, +code button, or +cursor button.
- In a WSL Terminal delete the folder
-
Manual Script Setup:
- Start Cursor and import your VS Code settings (ensure you have the WSL extension installed).
- Reload Cursor and connect it to WSL. Make sure
~/.cursor-server/bin/<your hash>folder is created and close cursor. - Refer to the comment https://github.com/getcursor/cursor/issues/807#issuecomment-1728885825
- In the script provided, replace the following:
COMMITwith your unique hash (you can find this in the newly created folder~/.cursor-server/bin/<your hash>).APP_NAME="code"withAPP_NAME="cursor".- Update
VSCODE_PATHwithVSCODE_PATH="$(dirname "$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")")"as instructed in the comments of this issue.
-
PATH Update for Cursor Script:
-
In the text editor where you saved the edited PATH string, add this path to the end:
:/mnt/c/Users/<your user>/AppData/Local/Programs/cursor/resources/app/bin -
In your WSL terminal run the following command, replacing
<new version>with the edited PATH string (use quotation marks if any path contains spaces):PATH="<new version>"
-
Important Note:
- Ensure the Cursor path in your PATH variable comes after the VS Code path. This prevents conflicts with a script named "code" in the Cursor path which was added to the PATH variable.
Persistent PATH Update (Optional):
-
To avoid manually setting the PATH every time you restart your terminal, you can add the following line to your shell configuration file (e.g.,
~/.zshrcfor Zsh or~/.bashrcfor Bash):PATH="<new version>"
Remember: After editing your shell configuration file, you need to source it for the changes to take effect. You can do this by running:
source ~/.zshrc # For Zsh
source ~/.bashrc # For Bash
This process should resolve your Cursor installation issues and allow you to launch it seamlessly within your WSL environment. By making the PATH update persistent in your shell configuration, you'll avoid the need to manually set it after every restart.
I have provided a tutorial in my repository, please check it https://github.com/angga7togk/command-cursor-editor-linux
This is still an issue and this is the only reliable fix I've found
It's unbelievable this is still broken after so many months, and the fix is rather simple. Sadly Cursor is not open source... but here's a quick workaround based on VS Code's current launcher from WSL:
Caution
This will most likely break after Cursor gets an update. Hopefully they'll fix this in the next update, but if not these tweaks may need to be done again after every update.
Note
You should install the WSL Extension before attempting these steps
Important
I opened a WSL folder at least once before doing these steps. Doing so installed Cursor's WSL Server in
~/.cursor-server/bin. I'm not sure if this altered VS Code script would trigger that too if you directly runcursorwithout the WSL Server installed.
Open the
cursorlinux script
Most likely located at
C:\Users\<your user>\AppData\Local\Programs\cursor\resources\app\bin\If you've installed the
cursorcommand you can also:
- Use
whichin WSL:$ which cursor /mnt/c/Users/lesmo/AppData/Local/Programs/cursor/resources/app/bin/cursor- Use
wherein Windows' Command Prompt:> where cursor c:\Users\lesmo\AppData\Local\Programs\cursor\resources\app\bin\cursor c:\Users\lesmo\AppData\Local\Programs\cursor\resources\app\bin\cursor.cmd- Use
(Get-Command cursor).Sourcein PowerShell :> (Get-Command code).Source C:\Users\lesmo\AppData\Local\Programs\Microsoft VS Code\bin\code.cmdCopy the
codelinux script contents into thecursorone
- Most likely located at
C:\Users\<your user>\AppData\Local\Programs\Microsoft VS Code\bin\Patch the script with:
Cursor values for the variables:
COMMITshould have the value of the binary under~/.cursor-server/bin, which for me right now is56becd74fc3058ee97a0b2496d8ae7ad2c2fcb10
APP_NAMEshould be"cursor"
NAMEshould be"Cursor"
SERVERDATAFOLDERshould be".cursor-server"
VSCODE_PATHshould be"$(dirname "$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")")"
- Paths slightly differ from VS Code, so this extra
dirnamecalls are necessary)Fix the semi-invalid output from the call to Cursor as CLI in line 47
- The
cat /tmp/remote-wsl-loc.txtexpects to only output a path, but it outputs 2 lines that breaks the script. To fix this, we forcibly get only the 2nd line:WSL_EXT_WLOC=$(cat /tmp/remote-wsl-loc.txt | head -2 | tail -1)Cursor will now be correctly launched by whatever WSL instance invokes it:
20240219_014531.mp4 This is my current
cursorfile contents:#!/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. if [ "$VSCODE_WSL_DEBUG_INFO" = true ]; then set -x fi COMMIT="56becd74fc3058ee97a0b2496d8ae7ad2c2fcb10" APP_NAME="cursor" QUALITY="stable" NAME="Cursor" SERVERDATAFOLDER=".cursor-server" VSCODE_PATH="$(dirname "$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")")" ELECTRON="$VSCODE_PATH/$NAME.exe" IN_WSL=false if [ -n "$WSL_DISTRO_NAME" ]; then # $WSL_DISTRO_NAME is available since WSL builds 18362, also for WSL2 IN_WSL=true else WSL_BUILD=$(uname -r | sed -E 's/^[0-9.]+-([0-9]+)-Microsoft.*|.*/\1/') if [ -n "$WSL_BUILD" ]; then if [ "$WSL_BUILD" -ge 17063 ]; then # WSLPATH is available since WSL build 17046 # WSLENV is available since WSL build 17063 IN_WSL=true else # If running under older WSL, don't pass cli.js to Electron as # environment vars cannot be transferred from WSL to Windows # See: https://github.com/microsoft/BashOnWindows/issues/1363 # https://github.com/microsoft/BashOnWindows/issues/1494 "$ELECTRON" "$@" exit $? fi fi fi if [ $IN_WSL = true ]; then export WSLENV="ELECTRON_RUN_AS_NODE/w:$WSLENV" CLI=$(wslpath -m "$VSCODE_PATH/resources/app/out/cli.js") # use the Remote WSL extension if installed WSL_EXT_ID="ms-vscode-remote.remote-wsl" ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" --locate-extension $WSL_EXT_ID >/tmp/remote-wsl-loc.txt 2>/dev/null </dev/null WSL_EXT_WLOC=$(cat /tmp/remote-wsl-loc.txt | head -2 | tail -1) if [ -n "$WSL_EXT_WLOC" ]; then # replace \r\n with \n in WSL_EXT_WLOC WSL_CODE=$(wslpath -u "${WSL_EXT_WLOC%%[[:cntrl:]]}")/scripts/wslCode.sh "$WSL_CODE" "$COMMIT" "$QUALITY" "$ELECTRON" "$APP_NAME" "$SERVERDATAFOLDER" "$@" exit $? fi elif [ -x "$(command -v cygpath)" ]; then CLI=$(cygpath -m "$VSCODE_PATH/resources/app/out/cli.js") else CLI="$VSCODE_PATH/resources/app/out/cli.js" fi ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@" exit $?P.S.: Cursor ppl, hire me? lol
Problem still exists
It's unbelievable this is still broken after so many months, and the fix is rather simple. Sadly Cursor is not open source... but here's a quick workaround based on VS Code's current launcher from WSL:
Caution
This will most likely break after Cursor gets an update. Hopefully they'll fix this in the next update, but if not these tweaks may need to be done again after every update.
Note
You should install the WSL Extension before attempting these steps
Important
I opened a WSL folder at least once before doing these steps. Doing so installed Cursor's WSL Server in
~/.cursor-server/bin. I'm not sure if this altered VS Code script would trigger that too if you directly runcursorwithout the WSL Server installed.
Open the
cursorlinux script
Most likely located at
C:\Users\<your user>\AppData\Local\Programs\cursor\resources\app\bin\If you've installed the
cursorcommand you can also:
- Use
whichin WSL:$ which cursor /mnt/c/Users/lesmo/AppData/Local/Programs/cursor/resources/app/bin/cursor- Use
wherein Windows' Command Prompt:> where cursor c:\Users\lesmo\AppData\Local\Programs\cursor\resources\app\bin\cursor c:\Users\lesmo\AppData\Local\Programs\cursor\resources\app\bin\cursor.cmd- Use
(Get-Command cursor).Sourcein PowerShell :> (Get-Command code).Source C:\Users\lesmo\AppData\Local\Programs\Microsoft VS Code\bin\code.cmdCopy the
codelinux script contents into thecursorone
- Most likely located at
C:\Users\<your user>\AppData\Local\Programs\Microsoft VS Code\bin\Patch the script with:
Cursor values for the variables:
COMMITshould have the value of the binary under~/.cursor-server/bin, which for me right now is56becd74fc3058ee97a0b2496d8ae7ad2c2fcb10
APP_NAMEshould be"cursor"
NAMEshould be"Cursor"
SERVERDATAFOLDERshould be".cursor-server"
VSCODE_PATHshould be"$(dirname "$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")")"
- Paths slightly differ from VS Code, so this extra
dirnamecalls are necessary)Fix the semi-invalid output from the call to Cursor as CLI in line 47
- The
cat /tmp/remote-wsl-loc.txtexpects to only output a path, but it outputs 2 lines that breaks the script. To fix this, we forcibly get only the 2nd line:WSL_EXT_WLOC=$(cat /tmp/remote-wsl-loc.txt | head -2 | tail -1)Cursor will now be correctly launched by whatever WSL instance invokes it:
20240219_014531.mp4 This is my current
cursorfile contents:#!/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. if [ "$VSCODE_WSL_DEBUG_INFO" = true ]; then set -x fi COMMIT="56becd74fc3058ee97a0b2496d8ae7ad2c2fcb10" APP_NAME="cursor" QUALITY="stable" NAME="Cursor" SERVERDATAFOLDER=".cursor-server" VSCODE_PATH="$(dirname "$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")")" ELECTRON="$VSCODE_PATH/$NAME.exe" IN_WSL=false if [ -n "$WSL_DISTRO_NAME" ]; then # $WSL_DISTRO_NAME is available since WSL builds 18362, also for WSL2 IN_WSL=true else WSL_BUILD=$(uname -r | sed -E 's/^[0-9.]+-([0-9]+)-Microsoft.*|.*/\1/') if [ -n "$WSL_BUILD" ]; then if [ "$WSL_BUILD" -ge 17063 ]; then # WSLPATH is available since WSL build 17046 # WSLENV is available since WSL build 17063 IN_WSL=true else # If running under older WSL, don't pass cli.js to Electron as # environment vars cannot be transferred from WSL to Windows # See: https://github.com/microsoft/BashOnWindows/issues/1363 # https://github.com/microsoft/BashOnWindows/issues/1494 "$ELECTRON" "$@" exit $? fi fi fi if [ $IN_WSL = true ]; then export WSLENV="ELECTRON_RUN_AS_NODE/w:$WSLENV" CLI=$(wslpath -m "$VSCODE_PATH/resources/app/out/cli.js") # use the Remote WSL extension if installed WSL_EXT_ID="ms-vscode-remote.remote-wsl" ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" --locate-extension $WSL_EXT_ID >/tmp/remote-wsl-loc.txt 2>/dev/null </dev/null WSL_EXT_WLOC=$(cat /tmp/remote-wsl-loc.txt | head -2 | tail -1) if [ -n "$WSL_EXT_WLOC" ]; then # replace \r\n with \n in WSL_EXT_WLOC WSL_CODE=$(wslpath -u "${WSL_EXT_WLOC%%[[:cntrl:]]}")/scripts/wslCode.sh "$WSL_CODE" "$COMMIT" "$QUALITY" "$ELECTRON" "$APP_NAME" "$SERVERDATAFOLDER" "$@" exit $? fi elif [ -x "$(command -v cygpath)" ]; then CLI=$(cygpath -m "$VSCODE_PATH/resources/app/out/cli.js") else CLI="$VSCODE_PATH/resources/app/out/cli.js" fi ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@" exit $?P.S.: Cursor ppl, hire me? lol
This is amazing! Thanks
can i ask you about your background and how you were able to debug this? @lesmo
It's unbelievable this is still broken after so many months, and the fix is rather simple. Sadly Cursor is not open source... but here's a quick workaround based on VS Code's current launcher from WSL:
Caution
This will most likely break after Cursor gets an update. Hopefully they'll fix this in the next update, but if not these tweaks may need to be done again after every update.
Note
You should install the WSL Extension before attempting these steps
Important
I opened a WSL folder at least once before doing these steps. Doing so installed Cursor's WSL Server in
~/.cursor-server/bin. I'm not sure if this altered VS Code script would trigger that too if you directly runcursorwithout the WSL Server installed.
Open the
cursorlinux script
Most likely located at
C:\Users\<your user>\AppData\Local\Programs\cursor\resources\app\bin\If you've installed the
cursorcommand you can also:
- Use
whichin WSL:$ which cursor /mnt/c/Users/lesmo/AppData/Local/Programs/cursor/resources/app/bin/cursor- Use
wherein Windows' Command Prompt:> where cursor c:\Users\lesmo\AppData\Local\Programs\cursor\resources\app\bin\cursor c:\Users\lesmo\AppData\Local\Programs\cursor\resources\app\bin\cursor.cmd- Use
(Get-Command cursor).Sourcein PowerShell :> (Get-Command code).Source C:\Users\lesmo\AppData\Local\Programs\Microsoft VS Code\bin\code.cmdCopy the
codelinux script contents into thecursorone
- Most likely located at
C:\Users\<your user>\AppData\Local\Programs\Microsoft VS Code\bin\Patch the script with:
Cursor values for the variables:
COMMITshould have the value of the binary under~/.cursor-server/bin, which for me right now is56becd74fc3058ee97a0b2496d8ae7ad2c2fcb10
APP_NAMEshould be"cursor"
NAMEshould be"Cursor"
SERVERDATAFOLDERshould be".cursor-server"
VSCODE_PATHshould be"$(dirname "$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")")"
- Paths slightly differ from VS Code, so this extra
dirnamecalls are necessary)Fix the semi-invalid output from the call to Cursor as CLI in line 47
- The
cat /tmp/remote-wsl-loc.txtexpects to only output a path, but it outputs 2 lines that breaks the script. To fix this, we forcibly get only the 2nd line:WSL_EXT_WLOC=$(cat /tmp/remote-wsl-loc.txt | head -2 | tail -1)Cursor will now be correctly launched by whatever WSL instance invokes it:
20240219_014531.mp4 This is my current
cursorfile contents:#!/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. if [ "$VSCODE_WSL_DEBUG_INFO" = true ]; then set -x fi COMMIT="56becd74fc3058ee97a0b2496d8ae7ad2c2fcb10" APP_NAME="cursor" QUALITY="stable" NAME="Cursor" SERVERDATAFOLDER=".cursor-server" VSCODE_PATH="$(dirname "$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")")" ELECTRON="$VSCODE_PATH/$NAME.exe" IN_WSL=false if [ -n "$WSL_DISTRO_NAME" ]; then # $WSL_DISTRO_NAME is available since WSL builds 18362, also for WSL2 IN_WSL=true else WSL_BUILD=$(uname -r | sed -E 's/^[0-9.]+-([0-9]+)-Microsoft.*|.*/\1/') if [ -n "$WSL_BUILD" ]; then if [ "$WSL_BUILD" -ge 17063 ]; then # WSLPATH is available since WSL build 17046 # WSLENV is available since WSL build 17063 IN_WSL=true else # If running under older WSL, don't pass cli.js to Electron as # environment vars cannot be transferred from WSL to Windows # See: https://github.com/microsoft/BashOnWindows/issues/1363 # https://github.com/microsoft/BashOnWindows/issues/1494 "$ELECTRON" "$@" exit $? fi fi fi if [ $IN_WSL = true ]; then export WSLENV="ELECTRON_RUN_AS_NODE/w:$WSLENV" CLI=$(wslpath -m "$VSCODE_PATH/resources/app/out/cli.js") # use the Remote WSL extension if installed WSL_EXT_ID="ms-vscode-remote.remote-wsl" ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" --locate-extension $WSL_EXT_ID >/tmp/remote-wsl-loc.txt 2>/dev/null </dev/null WSL_EXT_WLOC=$(cat /tmp/remote-wsl-loc.txt | head -2 | tail -1) if [ -n "$WSL_EXT_WLOC" ]; then # replace \r\n with \n in WSL_EXT_WLOC WSL_CODE=$(wslpath -u "${WSL_EXT_WLOC%%[[:cntrl:]]}")/scripts/wslCode.sh "$WSL_CODE" "$COMMIT" "$QUALITY" "$ELECTRON" "$APP_NAME" "$SERVERDATAFOLDER" "$@" exit $? fi elif [ -x "$(command -v cygpath)" ]; then CLI=$(cygpath -m "$VSCODE_PATH/resources/app/out/cli.js") else CLI="$VSCODE_PATH/resources/app/out/cli.js" fi ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@" exit $?P.S.: Cursor ppl, hire me? lol
working for me thanks !!!
got
/mnt/c/Users/xxx/.cursor/extensions/ms-vscode-remote.remote-wsl-0.81.8/scripts/wslCode.sh: 63: /home/xxx/.cursor-server/bin/fee1edb8d6d72a0ddff41e5f71a671c23ed924b9/bin/remote-cli/cursor: not found
I wish I had seen this before uninstalling vanilla vscode to get cursor up and running in WSL, uggh.
Unacceptable bug, removed the app until this is fixed
🤣 can't believe this is still broken after almost a year now
This is amazing! Thanks
can i ask you about your background and how you were able to debug this? @lesmo
@OmarNaguib just a software engineer, been doing this for a decade now... debugging is just like everything else: just follow the error messages and tweak things 'til it works 🤷♂️
Worked for me, thanks
You can try this:
- Open cursor, and connect to wsl
- Then run this
fixWSL.shin the wsl#!/usr/bin/env bash # Function to backup a file if it exists backup_file() { local file_path=$1 if [ -e "$file_path" ]; then mv "$file_path" "$file_path.bak" fi } # Function to safely copy a file and create a backup if it doesn't exist safe_copy_with_backup() { local src=$1 local dest=$2 cp "$src" "$dest" if [ ! -e "$dest.bak" ]; then cp "$dest" "$dest.bak" fi } # Function to perform the sed replacements perform_replacements() { local file_path=$1 local bin_path=$2 sed -i 's|APP_NAME="code"|APP_NAME="cursor"|' "$file_path" if [ -n "$bin_path" ]; then local commit commit=$(basename "$bin_path") sed -i "s|COMMIT=\"[^\"]*\"|COMMIT=\"$commit\"|" "$file_path" fi sed -i 's|NAME="Code"|NAME="Cursor"|' "$file_path" sed -i 's|SERVERDATAFOLDER=".vscode-server"|SERVERDATAFOLDER=".cursor-server"|' "$file_path" sed -i -E 's|VSCODE_PATH=".+"|VSCODE_PATH="$(dirname "$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")")"|' "$file_path" sed -i -E 's|WSL_EXT_WLOC=(.+)|WSL_EXT_WLOC=$(tail -1 /tmp/remote-wsl-loc.txt)|' "$file_path" } # Main script execution CODE_PATH=$(which code) if [[ "$CODE_PATH" == *"cursor"* ]]; then backup_file "$CODE_PATH" fi CODE_WIN_PATH=$(which code) CURSOR_WIN_PATH=$(which cursor) BIN_PATH=$(ls -d ~/.cursor-server/bin/*/ 2>/dev/null | head -n 1) safe_copy_with_backup "$CODE_WIN_PATH" "$CURSOR_WIN_PATH" perform_replacements "$CURSOR_WIN_PATH" "$BIN_PATH"
Fixed it perfectly. Thanks for the easy fix
thank you for breaking my dev setup wasted my 20 mins not using cursor
This issue should be fixed in today's 0.41.1 release!