cursor icon indicating copy to clipboard operation
cursor copied to clipboard

`cursor .` No such file or directory

Open k1lgor opened this issue 1 year ago • 1 comments

When updating the app and trying to open it via the terminal:

$ cursor .
/c/Users/User/AppData/Local/Programs/cursor/resources/app/bin/cursor: line 61: /c/Users/User/AppData/Local/Programs/cursor/resources/app/Cursor.exe: No such file or directory

The actual Cursor.exe is in ../resources/ dir.

I am using Windows 10

Workaround of ../resources/app/bin/cursor:

# line 14
- VSCODE_PATH="$(dirname "$(dirname "$(realpath "$0")")")"
+ VSCODE_PATH="$(dirname "$(dirname "$(dirname "$(dirname "$0")")")")"

This could help everyone with the same issue.

k1lgor avatar Feb 01 '24 16:02 k1lgor

I just installed v0.38.1 and got same issue on Windows 11

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

But now the actual Cursor.exe is in ../Programs/cursor/ dir. Workaround: in ../resources/app/bin/cursor::

# line 49
- VSCODE_PATH="$(dirname "$0")/.."
+ VSCODE_PATH="$(dirname "$0")/../../.."

devdavedotdev avatar Jul 29 '24 07:07 devdavedotdev

I'm facing the same issue on macOS with Cursor v0.39.6. See https://github.com/Homebrew/homebrew-cask/issues/183427. I saw some clever solutions here: https://github.com/getcursor/cursor/issues/1121#issuecomment-1863895663. But it should not be us users to fix the script on our end.

singularitti avatar Aug 26 '24 01:08 singularitti

On macOS you need to modify ELECTRON="$VSCODE_PATH/cursor" to ELECTRON="$VSCODE_PATH/MacOS/Cursor". The path is completely wrong...

And this doesn't even solve the following:

$ cursor .
grep: /proc/version: No such file or directory

which I believe is coming from these lines in /Applications/Cursor.app/Contents/Resources/app/bin/cursor:

# test that VSCode wasn't installed inside WSL
if grep -qi Microsoft /proc/version && [ -z "$DONT_PROMPT_WSL_INSTALL" ]; then

thegiantbeast avatar Aug 26 '24 19:08 thegiantbeast

Thanks! But it will be good to be fixed from the developer side.

singularitti avatar Aug 26 '24 19:08 singularitti

Of course, I was just leaving this here in case someone needs to have this working for the time being. but I totally agree that this needs to be fixed

thegiantbeast avatar Aug 27 '24 09:08 thegiantbeast

On macOS you need to modify ELECTRON="$VSCODE_PATH/cursor" to ELECTRON="$VSCODE_PATH/MacOS/Cursor". The path is completely wrong...

And this doesn't even solve the following:

$ cursor .
grep: /proc/version: No such file or directory

which I believe is coming from these lines in /Applications/Cursor.app/Contents/Resources/app/bin/cursor:

# test that VSCode wasn't installed inside WSL
if grep -qi Microsoft /proc/version && [ -z "$DONT_PROMPT_WSL_INSTALL" ]; then

Based on this comment and https://github.com/getcursor/cursor/issues/870, I was able to get it working.

Replace /opt/homebrew/bin/cursor content with

#!/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/MacOS/$NAME"

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 $?

patamimbre avatar Aug 27 '24 19:08 patamimbre