-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Use package root as cargo check working directory
#8819
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
Conversation
Cargo commands are affected by the `.cargo/config` files above their working directory. If cargo is invoked from above the directory holding `Cargo.toml`, it may not pick up important settings like registry replacements, causing it to behave differently or even fail. Most cargo invocations are currently setting their working directories to the directory containing `Cargo.toml`, but a couple of paths remain in which cargo is invoked from the default workspace root instead. This change fixes that, resolving some cargo check failures that I experienced in a multi-root workspace in which packages used different registries.
lf-
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OOOH YES! I like this change! I too have a cursed workspace, in my case, it's because the package wide cargo check is plain wrong due to the package specific cargo configs and targets. Thanks for doing it.
|
Great idea! Let’s remove the —manifest-path argument then! bors d+ |
Will do. |
|
bors r+ And this also is a negative diff, splendid! |
8819: Use package root as `cargo check` working directory r=matklad a=bcully Cargo commands are affected by the `.cargo/config` files above their working directory. If cargo is invoked from above the directory holding `Cargo.toml`, it may not pick up important settings like registry replacements, causing it to behave differently or even fail. Most cargo invocations are currently setting their working directories to the directory containing `Cargo.toml`, but a couple of paths remain in which cargo is invoked from the default workspace root instead. This change fixes that, resolving some cargo check failures that I experienced in a multi-root workspace in which packages used different registries. Co-authored-by: Brendan Cully <brendan@cully.org>
|
Build failed: |
|
I'm not sure what to make of the test failure. It looks like it's just |
|
Try |
|
Ah, this does reproduce 10 of the 11 failures on my mac. I'll take a closer look. |
|
Seems like some kind of path canonicalization issue. Here's a diff on mac of the metadata command in the test suite, comparing the call without an explicit When given a I'm inclined to just restore |
|
Actually, I'd like to just drop the second commit. Two tests still fail when only metadata gets |
|
As an added data point, this also gets the test suite to pass: but I doubt that is the correct fix, real users might also be using symlinks in their package directories. We should probably be doing the same normalization cargo is doing when we create the workspace roots. |
|
Alternatively perhaps we should update our config with the |
|
I think canonicalization tempdir is fine |
I guess something else is already canonicalizing the workspace root before giving it to the server, outside test code? I couldn't seem to trip up rust-analyzer on the command line: I'll canonicalize tempdir. It seems like the test code ought to pass through the same canonicalization that the real code uses though. |
|
... actually, I don't think we should just canonicalize tempdir. I installed this on a linux server where my homedir was a symlink, and it broke. I'm going to roll back these last two commits again and work on the path canonicalization issue separately. |
|
bors r+ |
Cargo commands are affected by the
.cargo/configfiles abovetheir working directory. If cargo is invoked from above the directory
holding
Cargo.toml, it may not pick up important settings likeregistry replacements, causing it to behave differently or even fail.
Most cargo invocations are currently setting their working directories
to the directory containing
Cargo.toml, but a couple of paths remainin which cargo is invoked from the default workspace root instead.
This change fixes that, resolving some cargo check failures that I
experienced in a multi-root workspace in which packages used different
registries.