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

ruff crash in remote developement (ssh) in VSCode #578

Open
ingempo opened this issue Aug 8, 2024 · 13 comments
Open

ruff crash in remote developement (ssh) in VSCode #578

ingempo opened this issue Aug 8, 2024 · 13 comments
Labels
needs-mre Needs more information for reproduction

Comments

@ingempo
Copy link

ingempo commented Aug 8, 2024

System info:

Host/Remote OS Name: Microsoft Windows 10 Enterprise
Host/Remote OS Version: 10.0.19044 N/A Build 19044
VSCode version: 1.92.1 (user setup)
Ruff version: 0.5.7
Python version: 3.9.13
Ruff log: ruff.log

settings.json:

"[python]":{
        "editor.defaultFormatter":"charliermarsh.ruff",
        "editor.wordBasedSuggestions":"matchingDocuments",
        "editor.formatOnType":true,
        "editor.formatOnSave":true,
        "editor.formatOnPaste":true,
        "editor.codeActionsOnSave":{
            "source.fixAll":"never",
            "source.organizeImports":"always"
        }
    },
  "python.analysis.typeCheckingMode":"basic",
  "python.analysis.completeFunctionParens":true, 
  "python.analysis.inlayHints.variableTypes":true,
  "python.analysis.inlayHints.functionReturnTypes":true,
  "python.analysis.inlayHints.callArgumentNames":"off",
  "python.analysis.inlayHints.pytestParameters":true,
  "python.analysis.enablePytestSupport":true,

Notes:

  • ruff works well on host and remote machines when vscode is launched locally.
  • pylance and python extensions seems to work well
@dhruvmanila
Copy link
Member

Hmm, this is weird. The logs says:

2024-08-08 17:42:52.601 [info] ruff failed
  Cause: Failed to convert workspace URL to file path: file:///work/hardware-qualification

But, the conversion succeeds:

Ok(
    Url {
        scheme: "file",
        cannot_be_a_base: false,
        username: "",
        password: None,
        host: None,
        port: None,
        path: "/work/hardware-qualification",
        query: None,
        fragment: None,
    },
)

@dhruvmanila
Copy link
Member

ruff works well on host and remote machines when vscode is launched locally.

Does this mean that this failure only occurs when VS Code is launched in the remote machine? How does that work?

@MichaReiser
Copy link
Member

MichaReiser commented Aug 9, 2024

@ingempo are you using WSL? I noticed that the log shows 2024-08-08 17:42:52.451 [info] Using interpreter: \work\hardware-qualification\.venv\Scripts\python.exe

Edit: Right, you're remoting

@ingempo
Copy link
Author

ingempo commented Aug 9, 2024

ruff works well on host and remote machines when vscode is launched locally.

Does this mean that this failure only occurs when VS Code is launched in the remote machine? How does that work?

Exactly ! ruff works well when I use vscode locally in the host (my own laptop) and remote (RDC) I don't know what happend.

@ingempo
Copy link
Author

ingempo commented Aug 9, 2024

@ingempo are you using WSL? I noticed that the log shows 2024-08-08 17:42:52.451 [info] Using interpreter: \work\hardware-qualification\.venv\Scripts\python.exe

Edit: Right, you're remoting

No, I'm not using WSL. Host and remote are physical windows machines. My project comes with its own python virtual env.
vscode uses this as default interpreter.

@ingempo
Copy link
Author

ingempo commented Aug 9, 2024

Hmm, this is weird. The logs says:

2024-08-08 17:42:52.601 [info] ruff failed
  Cause: Failed to convert workspace URL to file path: file:///work/hardware-qualification

But, the conversion succeeds:

Ok(
    Url {
        scheme: "file",
        cannot_be_a_base: false,
        username: "",
        password: None,
        host: None,
        port: None,
        path: "/work/hardware-qualification",
        query: None,
        fragment: None,
    },
)

Maybe the path has an extra slash at the beginning? It is weird for me to see a path with 3 slashes?

@MichaReiser
Copy link
Member

@dhruvmanila I could try to repro the conversion on windows if you want. The to_file_path method has some conditional compiled code in it.

@dhruvmanila
Copy link
Member

@MichaReiser Yeah, that would be useful, thanks.

@dhruvmanila
Copy link
Member

Maybe the path has an extra slash at the beginning? It is weird for me to see a path with 3 slashes?

No, the path is correct. The two slashes are part of the scheme, kind of like https://..., so file:// and then the path /work/hardware-qualification.

@dhruvmanila
Copy link
Member

@ingempo Can you try setting the following setting and see if the problem persists?

{
	"ruff.nativeServer": "off"
}

Currently, as per the logs, the extension is automatically using the native server. I'm guessing that ruff-lsp shouldn't be affected by this but it would be useful to confirm that.

@ingempo
Copy link
Author

ingempo commented Aug 12, 2024

Hi @dhruvmanila, sorry for delay.

Not success with:

{
	"ruff.nativeServer": "off"
}

Current ruff log:

2024-08-12 16:35:50.858 [info] Name: Ruff
2024-08-12 16:35:50.858 [info] Module: ruff
2024-08-12 16:35:50.859 [debug] Full Server Info: {"name":"Ruff","module":"ruff"}
2024-08-12 16:35:50.859 [info] Python extension loading
2024-08-12 16:35:50.859 [info] Waiting for interpreter from python extension.
2024-08-12 16:35:50.859 [info] Python extension loaded
2024-08-12 16:35:50.859 [info] Using interpreter: \work\hardware-qualification\.venv\Scripts\python.exe
2024-08-12 16:35:50.859 [info] Server run command: \work\hardware-qualification\.venv\Scripts\python.exe c:\Users\opalrtlinux\.vscode-server\extensions\charliermarsh.ruff-2024.38.0-win32-x64\bundled\tool\server.py
2024-08-12 16:35:50.859 [info] Server: Start requested.
2024-08-12 16:35:50.860 [debug] Server State: Starting
2024-08-12 16:35:50.860 [debug] Server State: Stopped
2024-08-12 16:35:50.860 [info] [Error - 4:35:49 p.m.] Ruff client: couldn't create connection to server.
2024-08-12 16:35:50.860 [info] Launching server using command \work\hardware-qualification\.venv\Scripts\python.exe failed. Error: spawn \work\hardware-qualification\.venv\Scripts\python.exe ENOENT
2024-08-12 16:35:50.860 [error] Server: Start failed: Launching server using command \work\hardware-qualification\.venv\Scripts\python.exe failed. Error: spawn \work\hardware-qualification\.venv\Scripts\python.exe ENOENT

python interprete is there:

Microsoft Windows [Version 10.0.19044.4529]
(c) Microsoft Corporation. All rights reserved.

(.venv) opalrtlinux@DEVOPS-WIP-01 C:\work\hardware-qualification>where python
C:\work\hardware-qualification\.venv\Scripts\python.exe

(.venv) opalrtlinux@DEVOPS-WIP-01 C:\work\hardware-qualification>python --version 
Python 3.9.13

@dhruvmanila
Copy link
Member

The interpreter path doesn't look correct as it's starting from \work\... instead of c:\work\... (?). Do you have the ruff.interpreter set anywhere in your VS Code config (global, workspace, per-folder)?

I noticed that you're using the VS Code server. So, the server is hosted on a Windows machine and are you accessing it via a local VS Code instance? How does SSH work here? I'm asking because the docs mentions that this doesn't require SSH connection.

@dhruvmanila dhruvmanila added the needs-mre Needs more information for reproduction label Aug 13, 2024
@ingempo
Copy link
Author

ingempo commented Aug 13, 2024

Hi !

I don't set ruff.interpreter in VS Code settings. And my setup is like you say, in other words: remote developement using ssh (https://code.visualstudio.com/docs/remote/ssh)

I don't get your question: How does SSH works here? I presume that in the link I gave you is the description of how SSH works for remote development setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels