Skip to content
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: Use dunce crate to get non-UNC paths when calling canonicalize #3502

Merged
merged 3 commits into from
Jan 12, 2024

Conversation

ericswanson-dfinity
Copy link
Member

Description

Call dunce::canonicalize rather than Path::canonicalize. On Linux/Macos, this just calls std::fs::canonicalize(), so no change there.

PathBuf::canonicalize on Windows generally returns Windows NT UNC paths like \\?\C:\Users\you\. Lots of programs, including Microsoft's, don't work with these kinds of paths. For example, npm will print out a message something like The current working directory is a UNC path. I'm going to use C:\Windows instead..

dunce:

... converts paths to legacy format whenever possible, but leaves UNC paths as-is when they can’t be unambiguously expressed in a simpler way. This allows legacy programs to access all paths they can possibly access, and UNC-aware programs to access all paths.

rust-lang/rust#42869 (comment)

Part of https://dfinity.atlassian.net/browse/SDK-1343

How Has This Been Tested?

Covered by existing tests on Linux/Macos.

Checklist:

I didn't put anything in the changelog because we don't release for Windows and there is no behavior change on Linux/Macos.

@mergify mergify bot merged commit 2fcc47b into master Jan 12, 2024
173 checks passed
@mergify mergify bot deleted the ens/dunce branch January 12, 2024 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants