Skip to content
This repository has been archived by the owner on Dec 22, 2024. It is now read-only.

Support WSL project/executable #56

Merged
merged 6 commits into from
Jun 22, 2024
Merged

Support WSL project/executable #56

merged 6 commits into from
Jun 22, 2024

Conversation

InSyncWithFoo
Copy link
Owner

Fixes #54.

Copy link

github-actions bot commented Jun 12, 2024

Qodana Community for JVM

It seems all right 👌

No new problems were found according to the checks applied

💡 Qodana analysis was run in the pull request mode: only the changed files were checked

View the detailed Qodana report

To be able to view the detailed Qodana report, you can either:

To get *.log files or any other Qodana artifacts, run the action with upload-result option set to true,
so that the action will upload the files as the job artifacts:

      - name: 'Qodana Scan'
        uses: JetBrains/[email protected]
        with:
          upload-result: true
Contact Qodana team

Contact us at [email protected]

@InSyncWithFoo InSyncWithFoo marked this pull request as draft June 12, 2024 10:08
@InSyncWithFoo InSyncWithFoo marked this pull request as draft June 12, 2024 10:08
@InSyncWithFoo InSyncWithFoo added the help wanted Extra attention is needed label Jun 14, 2024
@InSyncWithFoo
Copy link
Owner Author

InSyncWithFoo commented Jun 16, 2024

After many, many trial-and-error cycles, I think these are the key points:

GeneralCommandLine uses Command Prompt for Windows

WSLDistribution.patchCommandLine() is used to take care of this.

However, a new problem arised from there.

PyCharm interacts with the file system via its concept of VirtualFiles

File URIs in request and response objects seem to be derived from the .getUrl() method, whose return values may not be RFC-compliant and thus invalid URIs. For example, it may emit file:////wsl$/Ubuntu/home/user instead of file://wsl.localhost/Ubuntu/home/user. To make things worse, VirtualFileManager.findFileByUrl() doesn't accept correct file: URIs.

I tackle this by replacing file:////wsl$ with file://wsl.localhost and revert as necessary.

But that's not all.

Windows 11 uses wsl.localhost, whereas Windows 10 uses wsl$

I believe there are also APIs to differentiate the two versions, but I'm blocked by a final problem.

Working directory doesn't seem to be correctly recognized

False reportMissingImports are emitted, suggesting that there are problems with either the withWorkDirectory() call, how Pyright handles it, or both.

src / pkg / __init__.py importing from its sibling foo.py

For comparison, no such diagnostics are emitted for the same file structure on Windows.

As a bonus, a visible IllegalStateException might be thrown if your build is older than 2024.2 EAP 1, which has yet to be released.

Current progress

The latest commit (c91b226) should deal with the first two.

I asked about this on Slack about half a week ago, but no answers so far. Out of ideas for now.

@InSyncWithFoo
Copy link
Owner Author

Found a way: Only send (and receive) Linux paths, but reprocess those paths before passing them to the default LspServerDescriptor.findFileByUri(). This also cures the false reportMissingImports diagnostics above.

@InSyncWithFoo InSyncWithFoo removed the help wanted Extra attention is needed label Jun 16, 2024
@InSyncWithFoo InSyncWithFoo marked this pull request as ready for review June 16, 2024 13:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WSL support
1 participant