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

Resolving symlinked long path on Windows returns a DOS device path #295

Closed
sapphi-red opened this issue Nov 6, 2024 · 4 comments · Fixed by #306
Closed

Resolving symlinked long path on Windows returns a DOS device path #295

sapphi-red opened this issue Nov 6, 2024 · 4 comments · Fixed by #306

Comments

@sapphi-red
Copy link
Contributor

When resolving a symlinked file that has a long path, oxc-resolver returns a DOS device path (a path starting with \\?\) on Windows. I expect a normal path to be returned (a path without \\?\).

Reproduction

  1. Clone https://github.com/sapphi-red-repros/oxc-resolver-windows-long-path-dos-device-path-reproduction on Windows
  2. run pnpm i
  3. run node index.js
  4. the output is something like result \\?\D:\documents\GitHub\oxc-resolver-windows-long-path-dos-device-path-reproduction\node_modules\.pnpm\@vitejs+longfilename-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa_pdxfg5khqstn67ymcqlkhhhflu\node_modules\@vitejs\longfilename-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\index.js
@Boshen
Copy link
Member

Boshen commented Nov 6, 2024

} else if #[cfg(windows)] {
dunce::canonicalize(path)

If you are on windows, can you try and use the example https://github.com/oxc-project/oxc-resolver/blob/main/examples/resolver.rs and see what's happening here.

I'm not on windows and I don't understand windows path at all :-/

@sapphi-red
Copy link
Contributor Author

dunce::canonicalize seems to only trim \\?\ when the path is shorter than 260 chars.
https://gitlab.com/kornelski/dunce/-/blob/1ee29a83526c9f4c3618e1335f0454c878a54dcf/src/lib.rs#L176-180
On the other hand, libuv always strips \\?\ regardless of the char length.
https://github.com/libuv/libuv/blob/d4ab6fbba4669935a6bc23645372dfe4ac29ab39/src/win/fs.c#L2780-L2785

@sapphi-red
Copy link
Contributor Author

When using the path from Node.js side, it would be easier to use if \\?\ is always stripped. But I'm not sure if that is easier to use for the Rust side.

@Boshen
Copy link
Member

Boshen commented Nov 7, 2024

When using the path from Node.js side, it would be easier to use if \\?\ is always stripped. But I'm not sure if that is easier to use for the Rust side.

Rust side has no preference, we can strip it if things still work.

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 a pull request may close this issue.

2 participants