Is there WSL2 support?

Hello!

Trying to use Cursor with WSL2 (also with installed VisualStudio Code), but it return errors:

hunterxp@DESKTOP:~/self$ cursor .
Unable to determine app path from symlink : /mnt/c/Users/HUNTERxp/AppData/Local/Programs/cursor/resources/app/bin/code

I have checked twice, and file exists, but, looks like it made for Mac, because
cat /mnt/c/Users/HUNTERxp/AppData/Local/Programs/cursor/resources/app/bin/code

return:

#!/usr/bin/env bash
#
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.

# when run in remote terminal, use the remote cli
if [ -n "$VSCODE_IPC_HOOK_CLI" ]; then
        REMOTE_CLI="$(which -a 'cursor' | grep /remote-cli/)"
        if [ -n "$REMOTE_CLI" ]; then
                "$REMOTE_CLI" "$@"
                exit $?
        fi
fi

function app_realpath() {
        SOURCE=$1
        while [ -h "$SOURCE" ]; do
                DIR=$(dirname "$SOURCE")
                SOURCE=$(readlink "$SOURCE")
                [[ $SOURCE != /* ]] && SOURCE=$DIR/$SOURCE
        done
        SOURCE_DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
        echo "${SOURCE_DIR%%${SOURCE_DIR#*.app}}"
}

APP_PATH="$(app_realpath "${BASH_SOURCE[0]}")"
if [ -z "$APP_PATH" ]; then
        echo "Unable to determine app path from symlink : ${BASH_SOURCE[0]}"
        exit 1
fi
CONTENTS="$APP_PATH/Contents"
**ELECTRON="$CONTENTS/MacOS/Cursor"**
CLI="$CONTENTS/Resources/app/out/cli.js"
ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" --ms-enable-electron-run-as-node "$@"
exit $?

How to fix it?

Does it work if you initiate the WSL from within Cursor using the command pallette and typing “connect to wsl”?

I got the error:

Also trying to fix the file (/mnt/c/Users/HUNTERxp/AppData/Local/Programs/cursor/resources/app/bin/code) with direct path to executable files… And got the error in my previous message.

#!/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.

# when run in remote terminal, use the remote cli
if [ -n "$VSCODE_IPC_HOOK_CLI" ]; then
	REMOTE_CLI="$(which -a 'cursor' | grep /remote-cli/)"
	if [ -n "$REMOTE_CLI" ]; then
		"$REMOTE_CLI" "$@"
		exit $?
	fi
fi

# test that VSCode wasn't installed inside WSL
if grep -qi Microsoft /proc/version && [ -z "$DONT_PROMPT_WSL_INSTALL" ]; then
	echo "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." 1>&2
	printf "Do you want to continue anyway? [y/N] " 1>&2
	read -r YN
	YN=$(printf '%s' "$YN" | tr '[:upper:]' '[:lower:]')
	case "$YN" in
		y | yes )
		;;
		* )
			exit 1
		;;
	esac
	echo "To no longer see this prompt, start Cursor with the environment variable DONT_PROMPT_WSL_INSTALL defined." 1>&2
fi

# If root, ensure that --user-data-dir or --file-write is specified
if [ "$(id -u)" = "0" ]; then
	for i in "$@"
	do
		case "$i" in
			--user-data-dir | --user-data-dir=* | --file-write )
				CAN_LAUNCH_AS_ROOT=1
			;;
		esac
	done
	if [ -z $CAN_LAUNCH_AS_ROOT ]; then
		echo "You are trying to start Cursor as a super user which isn't recommended. If this was intended, please add the argument \`--no-sandbox\` and specify an alternate user data directory using the \`--user-data-dir\` argument." 1>&2
		exit 1
	fi
fi

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" --ms-enable-electron-run-as-node "$@"
exit $?

Could you try mkdiring /home/hunterxp/.cursor-server. Then running “fix wsl” in the command palette? Then retrying?

1 Like

hunterxp@DESKTOP:~$ pwd
/home/hunterxp
hunterxp@DESKTOP:~$ mkdir .cursor-server
mkdir: cannot create directory ‘.cursor-server’: File exists
hunterxp@DESKTOP:~$ cd .cursor-server
-bash: cd: .cursor-server: Not a directory

Try deleting the file?

1 Like


No error yet… will be back after completing download.

Not critical, but I have strange output while running the command:


Didn’t help.
Oh, I forgot to say that error appears after “Reopen Folder in WSL”
image

Ok thanks for doing that and sorry about this.

Trying to reproduce on my end. Will revert here if I have an update.

1 Like

Thanks in advance too!
It’s really cool that you are respond so quickly! :muscle:

Hello, just to say that I am facing the exact same issue (WSL2 on Windows 10).
When I try to run ‘cursor’ by itself on the WSL2 prompt, I get the following error:

martel@gluon:~$ cursor
/mnt/c/Users/martel/AppData/Local/Programs/cursor/resources/app/bin/cursor: 62: /mnt/c/Users/martel/AppData/Local/Programs/cursor/resources/app/bin/../cursor: not found
martel@gluon:~$

Thsnks,
Paulo

@pjmartel @hunterxp Could you confirm whether this test build works or not for wsl: https://download.cursor.sh/builds/230824pxci9bzib/windows/nsis/x64

I just installed that version and WSL already worked for me, I also had that problem with wsl

Just to be clear, did WSL work with that version downloaded or not? @AbhigaelCarranz

1 Like

image
yes

1 Like

Just pushed a new update (0.8.4) that applies the patch from Github across all your WSL (Windows Subsystem for Linux) distros.

If it doesn’t work automatically after you update, try running the the “Fix WSL” command through ctrl + shift + p.

Please let me know if WSL doesn’t work for you still.

Looks like everything is working now.

Okay, so removing .cursor-server and restarting with latest (0.8.4) seems to have fixed at least Connect to WSL and existing wsl workspaces… However, “cursor .” from wsl does not appear to work. Using ubuntu 20.04 in Windows Terminal I get:

~/.cursor-server/bin/74f6148eb9ea00507ec113ec51c489d6ffb4b771/bin/remote-cli/cursor .
Command is only available in WSL or inside a Visual Studio Code terminal.

or

/mnt/c/Users/dolan/AppData/Local/Programs/cursor/resources/app/bin/cursor .
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/dolan/AppData/Local/Programs/cursor/resources/app/bin/cursor: 62: /mnt/c/Users/dolan/AppData/Local/Programs/cursor/resources/app/bin/…/cursor: not found

Both commands do actually work from within Cursor’s terminal. FWIW, I never separately installed the linux version in WSL, beyond whatever Cursor running in windows installed for me. VSCode “code .” command works fine in WSL.

Any ideas? It’s very convenient to have the option of starting from the command line.

1 Like