Closed guidocioni closed 2 days ago
Sorry that you're facing this issue. This could be related to either https://github.com/astral-sh/ruff/issues/11366 or https://github.com/astral-sh/ruff/issues/13686 but I want to make sure which one it is so I'll need some additional information to understand the root cause of this specific issue. Can you provide the following?
ruff
executable used and the version of it.pyproject.toml
/ ruff.toml
/ .ruff.toml
) that's being used for this file / notebook?ruff.
i.e., the ones mentioned in https://docs.astral.sh/ruff/editors/settings/.Sorry that you're facing this issue. This could be related to either astral-sh/ruff#11366 or astral-sh/ruff#13686 but I want to make sure which one it is so I'll need some additional information to understand the root cause of this specific issue. Can you provide the following?
- Ruff extension version
v2024.52.0
- Debug logs for both the extension and the server. Refer to the troubleshooting guide. These logs will also include the
ruff
executable used and the version of it.
- What's the location of this notebook or Python script? Is it in a project or is it in a random directory on your file system?
I'm not opening a project in this case, but instead a notebook that is located in /Users/<user>/Documents/folder/notebook.ipynb
. However, I notice from the log that it is scanning a trashed python project to find a .toml
file....why?!?!
- Is there a Ruff configuration (
pyproject.toml
/ruff.toml
/.ruff.toml
) that's being used for this file / notebook?
No
- Can you provide the settings that you've set for the Ruff extension? This would be the one starting with
ruff.
i.e., the ones mentioned in https://docs.astral.sh/ruff/editors/settings/.
No custom setting besides the one now used to produce the log files
"ruff.trace.server": "messages"
Thanks for providing all the information. I think this is related to https://github.com/astral-sh/ruff/issues/11366 and is fixed in 0.7.1
. Can you try upgrading your Ruff version and check again?
Oh wait, you're using the bundled executable which is not yet upgraded to the latest version. I think this is an important bug fix that needs to go out in the bundled executable as well. I'll do that today.
Yeah I was about to ask how can I upgrade the bundled version of the server. In the meantime what would be a workaround? Install the server manually and change the settings?
Yes, you can install the ruff
executable globally via pipx
or uv tool install
that should be then available on PATH
. As you've no extension settings set, it should pickup the one from the environment i.e., PATH
and that can be seen in the logs:
Here, the second line says that the extension is using the bundled executable
2024-10-29 11:26:30.516 [info] Using interpreter: /Users/<user>/miniconda3/envs/default/bin/python
2024-10-29 11:26:30.656 [info] Falling back to bundled executable: /Users/<user>/.vscode/extensions/charliermarsh.ruff-2024.52.0-darwin-x64/bundled/libs/bin/ruff
2024-10-29 11:26:30.687 [info] Resolved 'ruff.nativeServer: auto' to use the native server
2024-10-29 11:26:30.697 [info] Found Ruff 0.7.0 at /Users/<user>/.vscode/extensions/charliermarsh.ruff-2024.52.0-darwin-x64/bundled/libs/bin/ruff
While, here you can see that it uses the global ruff binary which I've installed using uv tool install
:
2024-10-29 16:14:45.105 [info] Using interpreter: /Users/dhruv/playground/.venv/bin/python
2024-10-29 16:14:45.138 [info] Using the Ruff binary: /Users/dhruv/.local/bin/ruff
2024-10-29 16:14:45.495 [info] Found Ruff 0.7.1 at /Users/dhruv/.local/bin/ruff
2024-10-29 16:14:45.495 [info] Server run command: /Users/dhruv/.local/bin/ruff server
I've installed with conda instead, but it was picked automatically from the extension...and I can already see the speedup now! The issue does not seem to exist anymore :) Cannot believe it was so easy to fix it
Happy to hear that :)
Regardless, I'll be bumping the extension version now to provide the updated Ruff version.
Whenever I open a notebook or python script the startup of ruff server uses about 70-90% of the CPU. If this spike would be limited to just 1-3 seconds that wouldn't really be an issue. However, this seems to take quite long (about 15 seconds), which makes vscode (and the entire laptop) quite unresponsive for that time. This becomes a bottleneck if I'm trying to open a large project or just one file after another, as multiple ruff server instance are spawned.
Is there any way to control the threads used by ruff server, or just reduce the load at startup time?
I don't have the most powerful CPU out there, but also not the "worst" one: i7-9750H on a Macbook Pro 15-inch of 2019. Shouldn't this machine be capable of handling the load on server startup without hogging?