eclipse-platform / eclipse-platform/eclipse.platform
Inconsistent path normalization with WSL project locations
- Dominant language
- Java
- Stars
- 165
- Forks
- 174
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 22
Description
Hello,
when operating on a mounted [WSL](https://learn.microsoft.com/en-us/windows/wsl/) file system from within Windows, Eclipse shows inconsistencies regarding the `PROJECT_LOC` path variable in case of projects with non-standard locations.
1. When a project located in the WSL has just been created (or imported), the evaluated `PROJECT_LOC` path starts with `//WSL.LOCALHOST`.
2. However, after a restart of Eclipse, the evaluated `PROJECT_LOC` path starts with the lower-case variant `//wsl.localhost` now.
While this should not matter in the Windows world, the [LSP extensions for CDT](https://github.com/eclipse-cdt/cdt-lsp) seem to incorporate `PROJECT_LOC` in paths for communication with language servers. According to [this lsp4e maintainer](https://github.com/eclipse-lsp4e/lsp4e/discussions/880#discussioncomment-7658410), wrapping language servers in containers is a valid use case. The [`--path-mappings`](https://manpages.debian.org/bookworm/clangd-19/clangd-19.1.en.html) parameter of clangd enables such setups, too. However, if clangd is started from within the WSL, any path mapping is case-sensitive, of course. Thus, if Eclipse and clangd do not use the same path variants, clangd does not work at all. As a consequence, extra care (or a manual restart) is currently required for setting up projects with LSPs.
This might be regarded as a small issue, but it multiplies the confusion caused by Eclipse's (seemingly?) undocumented & non-obvious (but reasonable?) general normalization behavior for `PROJECT_LOC`. WSL-located projects that are placed at the "standard project locations" always produce a `PROJECT_LOC` value with the upper case variant. In the case of non-standard locations, they do not (or they do but only before the first restart). It took me quite a while to differentiate all those details until I felt confident about the stability of my setups. IMHO, at least, the normalization behaviour should be made consistent.
Note that the Windows "Open File" dialogs seem to provide only the lowercase variant of WSL paths while for the normal Windows paths, they provide paths with uppercase device letters.
How to reproduce (a standard Ubuntu WSL installation with the user "user" is assumed):
1. Create the needed directories from within the WSL with `mkdir -p ~/proof/ws ~/proof/projects/first`.
2. Start Eclipse from within Windows with the workspace path `\\wsl.localhost\Ubuntu\home\user\proof\ws`.
3. Create a new C++ project with project name "first" at the non-default location `\\wsl.localhost\Ubuntu\home\user\proof\projects\first`.
4. Look up the `PROJECT_LOC` value in the project properties at Resource -> Linked Resources. It is `\\WSL.LOCALHOST\Ubuntu\home\user\proof\projects\first`.
5. Restart Eclipse.
6. Look up the `PROJECT_LOC` value again. Now it is `\\wsl.localhost\Ubuntu\home\user\proof\projects\first`.
I observe the same behavior when importing existing projects into the workplace.
My overall Eclipse version:
Version: 2025-03 (4.35.0)
Build id: 20250306-0812
I'm not sure if the activation of the normalization is well known. Just in case you want to understand why it is enabled in default-located projects, my own code trace (take it with a grain of salt):
Behavior for default-located projects on startup
1. Evaluation of the `.location` file (this causes the deletion of the `FileStoreRoot`, see next step): https://github.com/eclipse-platform/eclipse.platform/blob/R4_35/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/LocalMetaArea.java#L324
2. The deletion of the project's `FileStoreRoot` object occurs here: https://github.com/eclipse-platform/eclipse.platform/blob/R4_35/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SaveManager.java#L971
3. In a later invocation of `getStoreRoot()` for the project, no `FileStoreRoot` object is found (since it was deleted): https://github.com/eclipse-platform/eclipse.platform/blob/R4_35/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/FileSystemResourceManager.java#L596
4. Thus, it is get from the `WorkspaceRoot`: https://github.com/eclipse-platform/eclipse.platform/blob/R4_35/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/FileSystemResourceManager.java#L627
5. The `WorkspaceRoot` does not have any either. Thus, it is created and receives a location: https://github.com/eclipse-platform/eclipse.platform/blob/R4_35/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/FileSystemResourceManager.java#L624
6. For that, the path is normalized by `realURI()` into the upper case variant: https://github.com/eclipse-platform/eclipse.platform/blob/R4_35/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/FileSystemResourceManager.java#L1112
However, I did not analyze why the normalization also occurs after creating/importing a project.
Contributor guide
Assessment
This issue has not been assessed yet.