-
Notifications
You must be signed in to change notification settings - Fork 5.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
fix(cli): realPath honors non-unc win32 path separator #6073
Conversation
|
'dunce' definitely seems to be engineered very diligently and the current canonicalize situation is indeed terrible, so I'm leaning towards landing this. That said, I do have some comments, maybe other windows users can chip in with their opinion on things:
|
@@ -577,12 +578,9 @@ fn op_realpath( | |||
debug!("op_realpath {}", path.display()); | |||
// corresponds to the realpath on Unix and | |||
// CreateFile and GetFinalPathNameByHandle on Windows | |||
let realpath = std::fs::canonicalize(&path)?; | |||
let mut realpath_str = | |||
into_string(realpath.into_os_string())?.replace("\\", "/"); |
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.
Sorry for the possibly dumb question. Isn't the cause of the wrong path separator simply the replacement in this line? What is it for?
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.
@nayeemrmn good catch, @piscisaureus PTAL
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.
I don't know what you guys think is wrong and what you expect.
I expect backslashes. So it was wrong and after this patch it is good.
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.
@piscisaureus Can we fix this by removing the \\ -> /
replacement (and maybe adapting the trim statement below), instead of bringing in a new dependency?
Description:
This PR tries to fix path separator returned by
realPah
.It looks like issue stemmed from rust-lang/rust#42869. Canonicalize on windows returns UNC path, stripping unc host (https://github.com/denoland/deno/blob/master/cli/ops/fs.rs?rgh-link-date=2020-06-02T04%3A57%3A06Z#L584) will leave rest of path do not honor win32 path separator. Given std canonicalize does not provide workaround yet, stripping UNC via drop-in replacement (gitlab.com/kornelski/dunce) seems the easiest way to fix instead of re-implementing UNC stripping logics.
It may possible using another crate may not be desired or other way to workaround may exist.