-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Append workspace paths using components #8874
Conversation
This improves the handling when cargo is run on windows using a UNC path as its working directory. See also: - #7986 - rust-lang/rust#42869
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Eh2406 (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
For past discussion see #8626 and #6198 and dtolnay/request-for-implementation#34. I think fixing all the things will be hard. But, This looks like a small reasonable change. If you can add a test that demonstrates where this helps, we my be up for merging this incremental improvement. |
Possible solution to #8626
I'm a bit confused as to why |
So join is implemented using This therefore does not change seperators, and since UNC paths (intentionally) do not handle The below is mostly speculative, but I think There is a world where I do agree an upstream convenience method for this (more common imo) case would be nice though, but this isn't a bug in std. It's worth noting that most of the other uses of |
Even this PR isn't 100% correct, but it should give better results. Once I have time to create a PR to integrate normpath, this issue should be fixed completely. |
Ignore this. |
This sort of sounds like a bug in |
The problem is that "add This just aligns the implementation with the intended semantics. I think the std semantics are correct, because otherwise |
More specifically, Cargo assumes that config files use relative paths, which is reasonable. The current directory being a verbatim path shouldn't change how the config file path is interpreted. However, libstd's |
I'm not against changing the behavior of |
Just a random note, another option might be to convert all |
That is a very good point That option is documented here I'm not sure how to do it using the stdlib APIs, without making it rather janky |
@ehuss I have tried to use that, and unfortunately the url crate doesn't support that (https://docs.rs/url/2.2.0/src/url/lib.rs.html#2551). For some reason cargo needs to create a URL, and that fails. This patch is still required for the planned rust-gpu build system to be usable on windows. |
It seems like discussion has stalled, but I would also like to voice that I would very much like for this fix to be merged, as there is no real workaround available. Having this fixed in I don't think that having that discussion should preclude cargo from fixing the couple of instances where it's clearly wrong though. Especially when fixes for Windows APIs in |
I do not object to this change. If the conversation has not come to a plan I will put it on the agenda at the next cargo meating. |
@Eh2406 Can you also discuss this related PR? It hasn't had much activity. |
I think there are two cases here, and I think Cargo should handle one of them and not the other. Cargo uses That said, once Cargo has translated to a The practical effect of this distinction: I think we should parse manifest paths into platform (We could likely catch most such cases if we could somehow get a message for every call we made to |
For implementing that, then our options would be to add a custom deserialise for the cargo/src/cargo/util/toml/mod.rs Lines 843 to 846 in d274fcf
which properly normalises the Both of these are more work than I'm able to put in just at the moment. I think @XAMPPRocky is on holiday for a while, so it's not urgent for the |
I don't think normalizing My suggestion above to use @DJMcNab, can you clarify what the actual problem was? Cargo should work fine with UNC paths (that is, network paths of the form Overall, I'd be reluctant to add a small hack like this, when there are many other places in Cargo where a |
Basically this is just the minimum viable hack to make cargo possibly work with a working directory longer than MAX_PATH, in the manner required for This explicitly does not try to handle any more complex cases, that is the workspace setup in rust-gpu does not require the use of |
If this is an issue, I created #8964 as a possible alternative. It fixes this issue too, and it's the first step of changing the type of |
Closing as this PR is quite old, and unfortunately it isn't entirely clear on how to proceed with fixing the Windows paths issues (and unfortunately none of us have much time to invest in this). I have opened #9769 as a meta issue to cover this. I understand this can be a frustrating issue to deal with, and this isn't saying we don't want it fixed (we very much do!), but that we want to better understand how to proceed. Thanks! |
I've been considering closing this myself for a while - just hadn't gotten around to it yet. As far as I know, rust-gpu has worked out a 'better' (for some definition thereof) workaround. |
This improves the handling when cargo is run on windows using
a UNC path as its working directory.
This error was met working on EmbarkStudios/rust-gpu#239.
An alternative implementation which would also be sufficient for rust-gpu would be to only append the new path's components, and keep the same format for
root_dir
.This could also be limited to the
expanded_list.push(pathbuf);
branch, if preferred, although this would prevent rust-gpu from using glob paths at all, which would be unfortunate.See also: