Inconsistent path normalization with WSL project locations
Hello,
when operating on a mounted WSL file system from within Windows, Eclipse shows inconsistencies regarding the PROJECT_LOC path variable in case of projects with non-standard locations.
- When a project located in the WSL has just been created (or imported), the evaluated
PROJECT_LOCpath starts with//WSL.LOCALHOST. - However, after a restart of Eclipse, the evaluated
PROJECT_LOCpath starts with the lower-case variant//wsl.localhostnow.
While this should not matter in the Windows world, the LSP extensions for CDT seem to incorporate PROJECT_LOC in paths for communication with language servers. According to this lsp4e maintainer, wrapping language servers in containers is a valid use case. The --path-mappings 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):
- Create the needed directories from within the WSL with
mkdir -p ~/proof/ws ~/proof/projects/first. - Start Eclipse from within Windows with the workspace path
\\wsl.localhost\Ubuntu\home\user\proof\ws. - Create a new C++ project with project name "first" at the non-default location
\\wsl.localhost\Ubuntu\home\user\proof\projects\first. - Look up the
PROJECT_LOCvalue in the project properties at Resource -> Linked Resources. It is\\WSL.LOCALHOST\Ubuntu\home\user\proof\projects\first. - Restart Eclipse.
- Look up the
PROJECT_LOCvalue 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
- Evaluation of the
.locationfile (this causes the deletion of theFileStoreRoot, 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 - The deletion of the project's
FileStoreRootobject 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 - In a later invocation of
getStoreRoot()for the project, noFileStoreRootobject 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 - 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 - The
WorkspaceRootdoes 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 - 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.