Skip to content

fix: Use the correct project root when there are multiple workspaces#21922

Open
Wilfred wants to merge 1 commit intorust-lang:masterfrom
Wilfred:proper_workspace_root
Open

fix: Use the correct project root when there are multiple workspaces#21922
Wilfred wants to merge 1 commit intorust-lang:masterfrom
Wilfred:proper_workspace_root

Conversation

@Wilfred
Copy link
Copy Markdown
Contributor

@Wilfred Wilfred commented Mar 31, 2026

Previously, Config::root_path() would always return the LSP rootUri of the first workspace folder. This can cause issues when the user has multiple workspaces open in their editor, especially if the first one in the list isn't a Rust project.

This was noted as an issue in #21483, and added comments suggesting that we should deprecate root_path().

This change splits root_path() into a workspace_root_for() function that handles the multiple workspace case correctly, and a default_root_path() fallback.

This is particularly useful when the user has configured project-relative paths to e.g. their discover command or rustfmt, but it's the correct behaviour in general.

AI disclosure: First draft was written with Claude Opus.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 31, 2026
Previously, Config::root_path() would always return the LSP rootUri of
the first workspace folder. This can cause issues when the user has
multiple workspaces open in their editor, especially if the first one
in the list isn't a Rust project.

This was noted as an issue in rust-lang#21483, and added
comments suggesting that we should deprecate root_path().

This change splits root_path() into a `workspace_root_for()` function
that handles the multiple workspace case correctly, and a
`default_root_path()` fallback.

This is particularly useful when the user has configured
project-relative paths to e.g. their discover command or rustfmt, but
it's the correct behaviour in general.

AI disclosure: First draft was written with Claude Opus.
@Wilfred Wilfred force-pushed the proper_workspace_root branch from 80e7c59 to 752da7d Compare March 31, 2026 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants