-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BatchDatabase::load_cargo fails on Windows #821
Comments
might be useful: https://gitlab.com/kornelski/dunce |
That indeed looks something that could fix this, at least temporarily until |
actually, @flodiebold, why do we call canonicalize there in the first place? It usually is better to just use paths as is: the fewer modifications to the path we do, the higher is the change that paths will work correctly. Original path might not be canonical, but it usually "works". |
The let local_roots = roots
.into_iter()
.filter(|r| vfs.root2path(*r).starts_with(&root))
.map(vfs_root_to_id)
.collect(); to find the local roots didn't work otherwise. There's probably a better way to do that, though... |
I need to check this, but I think what Cargo does is that it absolutize the path (using canonicalized path to cargo.exe) and doesn't do canonicalization |
yep, Cargo doesn't do canonicalization, it does only normalization: https://github.com/rust-lang/cargo/blob/2e4cfc2b7d43328b207879228a2ca7d427d188bb/src/cargo/util/paths.rs#L65 EDIT: here's how it is called https://github.com/rust-lang/cargo/blob/2e4cfc2b7d43328b207879228a2ca7d427d188bb/src/cargo/util/command_prelude.rs#L255 |
My suggested fix is to, first, try use the |
Currently, |
Could we join |
let path = std::env::current_dir()?;
let (db, roots) = BatchDatabase::load_cargo(path)?; In this case the call to |
So that means that inside |
That does seem to work. In both cases. |
Instead of using canonicalize, we now join the given path to `std::env::current_dir()`, which either replaces the path, if the given path is absolute, or joins the paths. This fixes rust-lang#821.
Closed the old PR and created new one with the join fix #825 |
825: Remove call to canonicalize in BatchDatabase::load_cargo r=matklad a=vipentti Instead of using canonicalize, we now join the given path to `std::env::current_dir()`, which either replaces the path, if the given path is absolute, or joins the paths. This fixes #821. Co-authored-by: Ville Penttinen <[email protected]>
Currently
BatchDatabase::load_cargo
fails on Windows due tocargo
not handling extended-length paths well, when either the current directory ormanifest-path
is an extended-length path (paths starting with\\?\
).See rust-lang/cargo#6198 for more details.
This causes both
test_loading_rust_analyzer
andcargo run --package ra_cli analysis-stats
to fail.The transform to an extended-length path on Windows is caused by
canonicalize
in:https://github.com/rust-analyzer/rust-analyzer/blob/65266c644a31e6b321e5afb3c5a2ee75be76cb0c/crates/ra_batch/src/lib.rs#L98
The actual fail happens in:
https://github.com/rust-analyzer/rust-analyzer/blob/65266c644a31e6b321e5afb3c5a2ee75be76cb0c/crates/ra_project_model/src/cargo_workspace.rs#L124
Output from running
test_loading_rust_analyzer
:The text was updated successfully, but these errors were encountered: