getcursor / cursor

The AI Code Editor
https://cursor.com
23.15k stars 1.47k forks source link

Simple replacement for Python/Pylance - we really need a walkthrough #1628

Open kyleboddy opened 1 month ago

kyleboddy commented 1 month ago

Is your feature request related to a problem? Please describe. Cursor does not offer a simple method to get Python interpreter + Pylance replacement working in the IDE. Tons of message board threads, posts, and issues are being ignored along with emails (mine, but presumably most others too).

Python symbols are no longer available and almost all hacks tend not to work; BasedPyright is hardly a replacement or remotely easy to configure.

Describe the solution you'd like A clear and simple document on what extensions to install and what configurations to use to get Python symbols, CTRL-click, and other basic functionality working in Cursor again.

Additional context Probably stop ignoring emails and customer service communications for one of your most requested features.

raphant commented 4 weeks ago

What OS are you using?

Those features are currently working on Macbook M2 Pro

image

Also Cursor Pyright extension but I think that is installed by default

kyleboddy commented 4 weeks ago

This is a known problem they don't give a full answer to:

https://forum.cursor.com/t/pylance-breaks-on-cursor-0-38-1/6920

kyleboddy commented 4 weeks ago

Cursor version:

image

If you install the Python extension, in VS Code the Pylance extension comes along for the ride. In Cursor latest, this doesn't happen, and on the default language server, you get this error, which you would expect since there is no Jedi language server installed:

image

If you download latest Pylance VSIX (2024.8.101 as of this post, updated 8/12/2024 per the VS code repo) and install it, you will get these errors:

image

Pylance blocks Cursor's ability to use it since it is a VS Code fork and not Microsoft's genuine software.

This is not really Cursor's fault, of course, and Microsoft earns some scorn here for not playing nice with forks (though they don't have to), but where blame lies with Cursor is the fact they don't address this in any sort of comprehensive manner with a walkthrough on alternatives for symbol resolution + command/control-click, type hinting/catching, etc - and instead relying instead on people suggesting BasedPyright (which is not feature complete and has plenty of problems itself).

kyleboddy commented 4 weeks ago

Per #1634 I deleted the .cursor-server directory on my remote machine and that fixed a Git extension problem - I figured I would see if this did anything for Pylance issues.

Unsurprisingly, no:

image

If the Cursor Language Server can be used as a stand-in for Jedi/Pylance, I have no idea where that documentation would be or how to do that.

Full log of the licensing problem Cursor is facing:

2024-08-15 07:35:53.999 [info] Experiment 'pythonCreateEnvOnPipInstall' is active
2024-08-15 07:35:53.999 [info] Experiment 'pythonRecommendTensorboardExt' is active
2024-08-15 07:35:53.999 [info] Experiment 'pythonSurveyNotification' is active
2024-08-15 07:35:53.999 [info] Experiment 'pythonTerminalEnvVarActivation' is active
2024-08-15 07:35:53.999 [info] Experiment 'pythonTestAdapter' is active
2024-08-15 07:35:54.577 [info] Test server listening.
2024-08-15 07:35:54.578 [info] Python interpreter path: /bin/python3
2024-08-15 07:35:55.121 [warning] Retry failed, storage update failed for key PYTHON_GLOBAL_STORAGE_KEYS
2024-08-15 07:35:55.122 [warning] Retry failed, storage update failed for key PYTHON_GLOBAL_STORAGE_KEYS
2024-08-15 07:35:55.762 [error] [
  'Failed to start language server, Class name = h, completed in 854ms, has a falsy return value, Arg 1: <Uri:/home/mocap>, Arg 2: 

{"id":"/bin/python3","sysPrefix":"/usr","envType":"Global","envName":"","envPath":"","path":"/bin/python3","architecture":3,"sysVersion":"3.12.3 (main, Jul 31 2024, 17:43:48) [GCC 13.2.0]","version":{"raw":"3.12.3","major":3,"minor":12,"patch":3,"build":[],"prerelease":["final","0"]},"displayName":"Python 3.12.3 64-bit","detailedDisplayName":"Python 3.12.3 64-bit"}, Arg 3: <argument cannot be serialized for logging>, Return Value: undefined',
  [s [Error]: Request initialize failed with message: You may install and use any number of copies of the software only with Microsoft Visual Studio, Visual Studio for Mac, Visual Studio Code, Azure DevOps, Team Foundation Server, and successor Microsoft products and services (collectively, the “Visual Studio Products and Services”) to develop and test your applications. The software is licensed, not sold. This agreement only gives you some rights to use the software. Microsoft reserves all other rights. You may not: work around any technical limitations in the software that only allow you to use it in certain ways; reverse engineer, decompile or disassemble the software, or otherwise attempt to derive the source code for the software, except and to the extent required by third party licensing terms governing use of certain open source components that may be included in the software; remove, minimize, block, or modify any notices of Microsoft or its suppliers in the software; use the software in any way that is against the law or to create or propagate malware; or share, publish, distribute, or lease the software (except for any distributable code, subject to the terms above), provide the software as a stand-alone offering for others to use, or transfer the software or this agreement to any third party.

    at /home/mocap/.cursor-server/extensions/ms-python.python-2023.14.0/out/client/extension.js:2:2310858
    at re (/home/mocap/.cursor-server/extensions/ms-python.python-2023.14.0/out/client/extension.js:2:2311152)
    at /home/mocap/.cursor-server/extensions/ms-python.python-2023.14.0/out/client/extension.js:2:2305936
    at Immediate.<anonymous> (/home/mocap/.cursor-server/extensions/ms-python.python-2023.14.0/out/client/extension.js:2:2305956)
    at process.processImmediate (node:internal/timers:478:21)] {
    code: -32603,
    data: undefined
  }

More specifically, the plain English warning Microsoft is sending:

Request initialize failed with message: You may install and use any number of copies of the software only with Microsoft Visual Studio, Visual Studio for Mac, Visual Studio Code, Azure DevOps, Team Foundation Server, and successor Microsoft products and services (collectively, the “Visual Studio Products and Services”) to develop and test your applications. The software is licensed, not sold. This agreement only gives you some rights to use the software. Microsoft reserves all other rights.

You may not: work around any technical limitations in the software that only allow you to use it in certain ways; reverse engineer, decompile or disassemble the software, or otherwise attempt to derive the source code for the software, except and to the extent required by third party licensing terms governing use of certain open source components that may be included in the software; remove, minimize, block, or modify any notices of Microsoft or its suppliers in the software; use the software in any way that is against the law or to create or propagate malware; or share, publish, distribute, or lease the software (except for any distributable code, subject to the terms above), provide the software as a stand-alone offering for others to use, or transfer the software or this agreement to any third party.

kyleboddy commented 4 weeks ago

Best I can do is to install the newest Python (which you usually have to do manually via VSIX due to some random ZIP file errors you get in Cursor) and BasedPyright, then turn off the vast majority of the type hinting, if not entirely disable it as BasedPyright has insane recommendations.

This will bring back Outline symbols on the left-hand side; the combination of BasedPyright (even with type checking fully disabled in extension settings) and ms-python's Python extension bring back at least that much functionality.

Still not sure what Cursor Language Server does though and how to select Pyright-compatible language servers with the Python extension, since it just offers Jedi (which crashes) and Pylance (which obviously is not supported).

image

kaandok commented 4 weeks ago

Here is a discussion that might help: https://github.com/VSCodium/vscodium/discussions/1641

kyleboddy commented 3 weeks ago

On a clean install of cursor (by nuking .cursor-server on the remote host) and attempting to install the recommended Python extension named by Cursor on popping up a .py file, here are the errors/warnings I get (not all related to Python, but wanted to include it for completeness).

Should probably go without saying that Python extension is not installed.

2024-08-17 04:09:17.853 [info] Extension host agent started.
2024-08-17 04:09:17.871 [info] Started initializing default profile extensions in extensions installation folder. file:///home/mocap/.cursor-server/extensions
2024-08-17 04:09:17.924 [info] [127.0.0.1][ef7e8ded][ManagementConnection] New connection established.
2024-08-17 04:09:17.959 [info] Completed initializing default profile extensions in extensions installation folder. file:///home/mocap/.cursor-server/extensions
2024-08-17 04:09:17.976 [info] [127.0.0.1][69017caa][ExtensionHostConnection] New connection established.
2024-08-17 04:09:18.108 [info] [127.0.0.1][69017caa][ExtensionHostConnection] <6281> Launched Extension Host Process.
2024-08-17 04:09:24.143 [info] Getting Manifest... ms-python.python
2024-08-17 04:09:24.380 [info] Installing extension: ms-python.python {"isMachineScoped":false,"installOnlyNewlyAddedFromExtensionPack":true,"isApplicationScoped":false,"profileLocation":{"$mid":1,"fsPath":"/home/mocap/.cursor-server/extensions/extensions.json","external":"file:///home/mocap/.cursor-server/extensions/extensions.json","path":"/home/mocap/.cursor-server/extensions/extensions.json","scheme":"file"},"productVersion":{"version":"0.39.5","date":"2024-08-14T17:01:36.569Z","vscodeVersion":"1.91.1"}}
2024-08-17 04:09:25.038 [info] Getting Manifest... anysphere.pyright
2024-08-17 04:09:26.099 [info] Installing extension: anysphere.pyright {"isMachineScoped":false,"installOnlyNewlyAddedFromExtensionPack":true,"isApplicationScoped":false,"profileLocation":{"$mid":1,"fsPath":"/home/mocap/.cursor-server/extensions/extensions.json","external":"file:///home/mocap/.cursor-server/extensions/extensions.json","path":"/home/mocap/.cursor-server/extensions/extensions.json","scheme":"file"},"productVersion":{"version":"0.39.5","date":"2024-08-14T17:01:36.569Z","vscodeVersion":"1.91.1"},"context":{"dependecyOrPackExtensionInstall":true}}
2024-08-17 04:09:26.115 [info] Started downloading extension: ms-python.python 2023.14.0 file:///home/mocap/.cursor-server/data/CachedExtensionVSIXs/cursor-ms-python.python-2023.14.0-universal
2024-08-17 04:09:26.117 [info] Started downloading extension: anysphere.pyright 1.1.327 file:///home/mocap/.cursor-server/data/CachedExtensionVSIXs/cursor-anysphere.pyright-1.1.327-universal
2024-08-17 04:09:26.559 [warning] Failed downloading sigzip. End of central directory record signature not found. Either not a zip file, or file is truncated.. Retry again... ms-python.python
2024-08-17 04:09:26.678 [warning] Failed downloading sigzip. End of central directory record signature not found. Either not a zip file, or file is truncated.. Retry again... ms-python.python
2024-08-17 04:09:26.809 [error] Error while installing the extension ms-python.python End of central directory record signature not found. Either not a zip file, or file is truncated. file:///home/mocap/.cursor-server/extensions/extensions.json
2024-08-17 04:09:27.812 [error] Error: End of central directory record signature not found. Either not a zip file, or file is truncated.
    at y (/home/mocap/.cursor-server/bin/274e2e5d572bd0b99449183635a0f94c7b9f54d0/out/vs/server/node/server.main.js:114:25872)
    at /home/mocap/.cursor-server/bin/274e2e5d572bd0b99449183635a0f94c7b9f54d0/out/vs/server/node/server.main.js:114:27315
    at /home/mocap/.cursor-server/bin/274e2e5d572bd0b99449183635a0f94c7b9f54d0/node_modules/yauzl/index.js:40:7
    at /home/mocap/.cursor-server/bin/274e2e5d572bd0b99449183635a0f94c7b9f54d0/node_modules/yauzl/index.js:190:5
    at /home/mocap/.cursor-server/bin/274e2e5d572bd0b99449183635a0f94c7b9f54d0/node_modules/yauzl/index.js:712:5
    at /home/mocap/.cursor-server/bin/274e2e5d572bd0b99449183635a0f94c7b9f54d0/node_modules/yauzl/fd-slicer.js:33:7
    at FSReqCallback.wrapper [as oncomplete] (node:fs:688:5)
2024-08-17 04:09:28.188 [error] Could not load vsce-sign module Cannot find module '@vscode/vsce-sign'
Require stack:
- /home/mocap/.cursor-server/bin/274e2e5d572bd0b99449183635a0f94c7b9f54d0/out/server-main.js
2024-08-17 04:09:28.188 [info] Extension signature verification is not done: anysphere.pyright
2024-08-17 04:09:32.163 [info] Extracted extension to file:///home/mocap/.cursor-server/extensions/anysphere.pyright-1.1.327-universal: anysphere.pyright
2024-08-17 04:09:32.239 [info] Renamed to /home/mocap/.cursor-server/extensions/anysphere.pyright-1.1.327-universal
2024-08-17 04:09:32.269 [info] Rollback: Uninstalled extension anysphere.pyright
2024-08-17 04:09:32.272 [info] Marked extension as uninstalled anysphere.pyright-1.1.327-universal
kyleboddy commented 3 weeks ago

Here is a discussion that might help: VSCodium/vscodium#1641

I am aware of this workaround, but it no longer works.

kyleboddy commented 3 weeks ago

It’s clear the Cursor team is either legally disallowed from talking about this issue or just don’t care about customer service anymore. Either way, I’ll be back when and if these things change. Rather sad to see.

@truell20

hongqiww commented 3 weeks ago

Same here. I only tried python and ruby, and neither of them works because of the language server issue.

teneon commented 3 weeks ago

Since Pylance is not working with cursor, that's a dealbreaker for me. I will also have to wait until this issue is resolved.

jimzer commented 2 weeks ago

Too bad! Just downloaded Cursor, tried on TypeScript -> awesome so far But I can't work properly on my Python projects which is a deal break for me too :(

Keep up the great work and let us know when Python works :)

kyleboddy commented 1 week ago

While Pylance remains broken, on the newest Cursor build and in a new server setup via remote-ssh, you get prompted to install the Python extension (ms-python) which installs version v2024.5.1. After restarting, I can confirm the Outline shows up and Python symbols have returned.

Still not enough - especially with no walkthrough on how Cursor Pyright even works - but this is a good step forward.

image

arkaydeus commented 3 days ago

IF you nuke your ~/.cursor/extensions folder, create a new user on your mac, install Cursor fresh with no import from VSC, then open a .py file, it will install a version of Pylance that does work.

Then you can copy your ~/.cursor/extensions folder over to the old user and bingo... it now works.