Skip to content

flake8_lint plugin: Popen fails when no workspace given by language server client on Windows #406

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

Closed
Oddegamra opened this issue Jul 26, 2023 · 3 comments · Fixed by #434
Labels
bug Something isn't working
Milestone

Comments

@Oddegamra
Copy link

I'm using Neovim as LSP client on Windows. When Neovim cannot detect a workspace for a given Python document, it runs in "single file mode". Thath is, the workspace root directory is passed to the language server as empty string.

Now, in flake8_lint.py, ever since commit 59de0f81, the flake8 executable is run with the working directory set to the workspace root directory. However, on Windows, giving an empty working directory results in Popen throwing a WinError 123. Thus, flake8 is never successfully started.

Maybe the working directory should be set to the document directory instead if the workspace is indeed empty.

@ccordoba12
Copy link
Member

Hey @Oddegamra, thanks for reporting. You said:

Thath is, the workspace root directory is passed to the language server as empty string.

I think this is incorrect, the root directory should be a directory. Perhaps Neovim could create and set an empty directory in the filesystem for the root directory (that's what we do in Spyder).

Maybe the working directory should be set to the document directory instead if the workspace is indeed empty.

I don't agree with that because it could create more problems that it could fix.

@Oddegamra
Copy link
Author

Oddegamra commented Jul 26, 2023

Correct me if I'm wrong, but the LSP specification seems to be quite clear on this: The workspace root folder is allowed to be empty if not configured/available. Passing a bogus folder as workspace root just seems plain wrong.

 * The workspace folders configured in the client when the server starts.
 * This property is only available if the client supports workspace folders.
 * It can be `null` if the client supports workspace folders but none are
 * configured.

Maybe simply leaving the working directory alone for the flake8 executable (when the workspace root is invalid) would be a better solution? Though I admit that I do not know exactly what implication the working directory has for flake8's execution, I haven't debugged/investigated that far.

@ccordoba12
Copy link
Member

Maybe simply leaving the working directory alone for the flake8 executable (when the workspace root is invalid) would be a better solution?

Yeah, that's a good idea. Could you send a pull request with that change?

Though I admit that I do not know exactly what implication the working directory has for flake8's execution, I haven't debugged/investigated that far.

It's used to detect the flake8 settings, according to #311.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants