Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work multiroot workspace with remote development #654

Open
Real-Gecko opened this issue Dec 17, 2024 · 17 comments
Open

Does not work multiroot workspace with remote development #654

Real-Gecko opened this issue Dec 17, 2024 · 17 comments
Labels
bug Something isn't working multi-root-workspaces Related to https://code.visualstudio.com/docs/editor/workspaces/multi-root-workspaces

Comments

@Real-Gecko
Copy link

Following #652 here's the problem: f I open multiroot workspace on remote server Ruff does not work, however if I just open folder(root folder where .code-workspace is) Ruff starts working.
Setting this one does not help:

{
  "ruff.importStrategy": "useBundled"
}

Might also be related to #653

@Real-Gecko
Copy link
Author

Note: I've connected to new server where Ruff is not installed at all, and it's not in .venv

@MichaReiser
Copy link
Member

Hmm interesting. Would you be able to share some logs with us? See the troubleshooting section for how you can enable logging

@Real-Gecko
Copy link
Author

Hmm interesting. Would you be able to share some logs with us? See the troubleshooting section for how you can enable logging

I've set "ruff.trace.server": "verbose" in my settings.json but the only thing I see in Ruff logs is:

2024-12-27 08:46:05.413 [info] Name: Ruff
2024-12-27 08:46:05.413 [info] Module: ruff
2024-12-27 08:46:05.413 [info] Python extension loading
2024-12-27 08:46:05.413 [info] Waiting for interpreter from python extension.
2024-12-27 08:46:05.413 [info] Python extension loaded
2024-12-27 08:46:05.413 [info] Using interpreter: /path/to/project/.venv/bin/python

@MichaReiser
Copy link
Member

Hmm interesting. An older Ruff version had a bug where it got stuck after the using interpreter message but I assume you're using a recent version of the Ruff extension?

Can you try pinning the Ruff status in the VS code toolbar. Does it show Ruff (native), Ruff (ruff-lsp) or does it have a spinning icon next to it (which would suggest it got stuck during startup)?

@AndreasBackx
Copy link

AndreasBackx commented Dec 28, 2024

I seem to have this issue as well. Pinning Ruff leads to a spinning icon next to it.

I've found a workaround for now: select the interpreter at the workspace level. That seems to do the trick instead of doing it for a specific folder.

@MichaReiser
Copy link
Member

I seem to have this issue as well. Pinning Ruff leads to a spinning icon next to it.

Thanks. That's interesting. It suggests that Ruff gets stuck during startup. @dhruvmanila do you have an idea why this is happening?

@Real-Gecko
Copy link
Author

I seem to have this issue as well. Pinning Ruff leads to a spinning icon next to it.

I've found a workaround for now: select the interpreter at the workspace level. That seems to do the trick instead of doing it for a specific folder.

Exactly same issue, constantly spinning icon next to Ruff
Image

@MichaReiser
Copy link
Member

Thanks. That's helpful because it means we can narrow it down to Ruff getting stuck during startup.

@MichaReiser MichaReiser added the bug Something isn't working label Dec 30, 2024
@MichaReiser
Copy link
Member

I tried reproducing the bug using GitHub code spaces but ruff works as expected, even with multiple workspaces. Which is disappointing in this case.

Could someone open and share the output of the Output - Extension Host (Remote?) tab. You should see something like this if the Ruff extension fails to start with an exception

2024-12-31 13:37:36.100 [warning] Accessing a resource scoped configuration without providing a resource is not expected. To get the effective value for 'files.watcherExclude', provide the URI of a resource or 'null' for any resource.
2024-12-31 13:37:36.100 [warning] Accessing a resource scoped configuration without providing a resource is not expected. To get the effective value for 'files.watcherExclude', provide the URI of a resource or 'null' for any resource.
2024-12-31 13:37:36.998 [error] Error: Whoopos
	at startServer (/Users/micha/astral/ruff-vscode/dist/extension.js:21740:11)
	at async runServer (/Users/micha/astral/ruff-vscode/dist/extension.js:25610:24)
	at async kh.value (/Users/micha/astral/ruff-vscode/dist/extension.js:25622:9)

@chazmo03
Copy link

chazmo03 commented Jan 8, 2025

I also encountered this issue. From the logs, it looks like it's using the python interpreter from one of the folders in my workspace, just not the one that I want it to use.

I tried doing Python: Select Interpreter > Select at workspace level but that seemed to have no effect.

One workaround is to explicitly set the interpreter in the workspace settings, e.g.:

  "ruff.interpreter": [
    "${workspaceFolder:desired-folder-name}/path/to/python"
  ]

@dhruvmanila
Copy link
Member

@chazmo03 Apologies for the late reply, can you share a minimal directory structure which I can use to reproduce this issue?

From the logs, it looks like it's using the python interpreter from one of the folders in my workspace, just not the one that I want it to use.

For context, the extension will try to get the Python interpreter details from the Python extension if not provided via ruff.interpreter:

export async function getInterpreterDetails(resource?: Uri): Promise<IInterpreterDetails> {
const api = await getPythonExtensionAPI();
const environment = await api?.environments.resolveEnvironment(
api?.environments.getActiveEnvironmentPath(resource),
);
if (environment?.executable.uri && checkVersion(environment)) {
return { path: [environment?.executable.uri.fsPath], resource };
}
return { path: undefined, resource };
}

@kdkavanagh
Copy link

Can confirm that setting this in my workspace config fixed the issue, even tho this was the interpreter being detected by ruff (according to logs) before applying this setting:

"ruff.interpreter": [
			"${workspaceFolder}/.venv/bin/python"
		]

@dhruvmanila
Copy link
Member

@kdkavanagh If you don't mind, I'd love to get the logs for the scenario where it's not working along with the directory structure and VS Code settings :)

@chazmo03
Copy link

@dhruvmanila, I'm not doing anything special, just 3 folders - 1 with my main python project and 2 other non-python projects.

In the above getInterpreterDetails function, it looks like it would need the resource to be supplied so that it can identify which environment/workspace that file belongs to, but when that function is called from initializePython, no resource is supplied. Could that be causing the issue?

@danieleds
Copy link

For me, a similar problem went away after I copied my vscode settings from my code workspace root into the workspace folder:

{
    "[python]": {
        "editor.formatOnSave": true,
        "editor.defaultFormatter": "charliermarsh.ruff"
    }
}

as if the extension wasn't able to properly make sense of the root-level settings.

@rdbisme
Copy link

rdbisme commented Jan 30, 2025

I had the same problem, related to multi-root, and I believe it's related to the Python extension caching things in a bad way.

If you do Python: Clear Cache and Reload Window makes it work again for me.

@rdbisme
Copy link

rdbisme commented Jan 30, 2025

PS: this was impossible to debug using Troubleshooting because it was hanging before, apparently, it read my JSON. So I got no log level change or log file which I had configured. Maybe you want to make that to get resolved earlier.

@dhruvmanila dhruvmanila added the multi-root-workspaces Related to https://code.visualstudio.com/docs/editor/workspaces/multi-root-workspaces label Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working multi-root-workspaces Related to https://code.visualstudio.com/docs/editor/workspaces/multi-root-workspaces
Projects
None yet
Development

No branches or pull requests

8 participants