Skip to content

get_project_root() fails to canonicalize Windows drive-letter URIs (leading slash not stripped) #292

Description

@Hanatarou

Description

get_project_root() in lsp.rs parses folder.uri.path() / root_uri.path()
directly via PathBuf::from_str, without stripping the leading / that
file:// URIs prepend before a Windows drive letter per RFC 8089.

On Windows, PathBuf::from_str("/C:/Users/...") does not recognize C: as
a drive prefix when preceded by / — it's parsed as RootDir followed by
a literal folder named "C:". .canonicalize() then always fails,
regardless of whether the path contains spaces or non-ASCII characters.

Impact

.asm-lsp.toml project config is never discovered via rootUri/
workspaceFolders on Windows — this affects every standard LSP client,
since file:///C:/... is the normal, spec-compliant way to represent a
Windows absolute path. Only the deprecated rootPath field (a raw OS
path string, not a URI) bypasses the bug, since it skips URI parsing
entirely.

Repro

  1. Start asm-lsp with any LSP client on Windows.
  2. Send initialize with rootUri: "file:///C:/some/project" (no
    rootPath field).
  3. Observe WARN [asm_lsp::lsp] Failed to detect project root in the log,
    even though C:\some\project\.asm-lsp.toml exists.

Suggested fix

Strip a leading / when the remainder matches ^[A-Za-z]: before
constructing the PathBuf, in both the workspace_folders and root_uri
branches of get_project_root().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions