flake8_lint plugin: Popen fails when no workspace given by language server client on Windows
Closed this issue · 3 comments
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.
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.
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.
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.