You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Mounted Volume in the path causes incorrect resolution output #65
When resolving for a module, if there is a mount point instead of ordinary folder within the path of the resolved file, unrs-resolver gives incorrect outputs.
Thanks for the detailed reproduction, it's much appreciated! But I'm sorry I don't have a Windows computer, do you familiar with Rust and want to contribute? That would be great thanks. I may get a Windows VM to work with later.
By the way, can you help to test does this issue also apply for oxc-resolver?
Especially, FileSystemOs::strip_windows_prefix didn't take care of the case where path is an UNC path pointing to a Volume (Drive) without Drive letter, namely, something like this
\\?\Volume{3b0ca266-7f02-4f2c-938c-50931634f3fb}\
IMO if we were going to resolve the path to its real link target, we should keep this UNC path here as-is, because the path above cannot be furtherly reduced.
However, nodejs seems still have trouble importing from UNC path directly. I haven't found any explicit statement on whether this is supported, but here are some attempts on Node 22.7.0:
WelcometoNode.jsv22.7.0.Type".help"formoreinformation.>constfs=require("fs")undefined// We cannot import module with UNC path>require(String.raw`\\?\Volume{3b0ca266-7f02-4f2c-938c-50931634f3fb}\foo.ts`)
Uncaught:
Error: EISDIR: illegaloperationonadirectory,lstat 'Volume{3b0ca266-7f02-4f2c-938c-50931634f3fb}\'
atObject.realpathSync(node:fs:2663:25)attoRealPath(node:internal/modules/helpers:53:13)atModule._findPath(node:internal/modules/cjs/loader:763:24)atModule._resolveFilename(node:internal/modules/cjs/loader:1234:27)atModule._load(node:internal/modules/cjs/loader:1074:27)atTracingChannel.traceSync(node:diagnostics_channel:315:14)atwrapModuleLoad(node:internal/modules/cjs/loader:217:24)atModule.require(node:internal/modules/cjs/loader:1339:12)atrequire(node:internal/modules/helpers:126:16){errno: -4068,code: 'EISDIR',syscall: 'lstat',path: 'Volume{3b0ca266-7f02-4f2c-938c-50931634f3fb}\\'}// However, things work if we use an ordinary path, even if `mount-root` is a Mounted Volume.>require(String.raw`D:\test\unrs-resolver-mounted-partition\src\mount-root\foo.ts`){}// Actually we cannot access UNC path of the drive root> fs.lstatSync(String.raw`\\?\Volume{3b0ca266-7f02-4f2c-938c-50931634f3fb}`)Uncaught:Error: EISDIR: illegal operation on a directory, lstat 'Volume{3b0ca266-7f02-4f2c-938c-50931634f3fb}\' at Object.lstatSync (node:fs:1634:25) { errno: -4068, code: 'EISDIR', syscall: 'lstat', path: 'Volume{3b0ca266-7f02-4f2c-938c-50931634f3fb}\\'}// We can, however, access UNC path of any files or sub-directories> fs.lstatSync(String.raw`\\?\Volume{3b0ca266-7f02-4f2c-938c-50931634f3fb}\foo.ts`)Stats { dev: 283819367, mode: 33206, nlink: 1, uid: 0, gid: 0, rdev: 0, blksize: 4096, ino: 8444249301520764, size: 0, blocks: 0, atimeMs: 1744717190861.8555, mtimeMs: 1744717190861.8555, ctimeMs: 1744717195891.9143, birthtimeMs: 1744717190861.8555}> fs.lstatSync(String.raw`\\?\Volume{3b0ca266-7f02-4f2c-938c-50931634f3fb}\@azure`)Stats{dev: 283819367,mode: 16822,nlink: 1,uid: 0,gid: 0,rdev: 0,blksize: 4096,ino: 281474976719715,size: 0,blocks: 8,atimeMs: 1744799573976.584,mtimeMs: 1725364495016.3733,ctimeMs: 1725364495016.3733,birthtimeMs: 1678773171142.6729}
Given the status quo of the supportability of the imports with UNC-path, probably we can just treat such symlinks resolved into UNC paths just like ordinary folders. This also aligns with the behavior of enhanced-resolve.
Activity
JounQin commentedon Apr 15, 2025
Thanks for the detailed reproduction, it's much appreciated! But I'm sorry I don't have a Windows computer, do you familiar with Rust and want to contribute? That would be great thanks. I may get a Windows VM to work with later.
By the way, can you help to test does this issue also apply for
oxc-resolver?chenxinyanc commentedon Apr 16, 2025
I'm not, unfortunately 🌚
However, I've just get started and done a bit investigation. I think the issue is with
FileSystemOs::read_link(&Path).unrs-resolver/src/file_system.rs
Line 193 in a2a4a11
Especially,
FileSystemOs::strip_windows_prefixdidn't take care of the case wherepathis an UNC path pointing to a Volume (Drive) without Drive letter, namely, something like thisIMO if we were going to resolve the path to its real link target, we should keep this UNC path here as-is, because the path above cannot be furtherly reduced.
However, nodejs seems still have trouble importing from UNC path directly. I haven't found any explicit statement on whether this is supported, but here are some attempts on Node 22.7.0:
Given the status quo of the supportability of the
imports with UNC-path, probably we can just treat such symlinks resolved into UNC paths just like ordinary folders. This also aligns with the behavior ofenhanced-resolve.chenxinyanc commentedon Apr 16, 2025
@JounQin Then I think the issue would probably also apply for
osc-resolver. Let's continue the discussion in oxc-project/oxc-resolver/issues/454.test: add case for #65 (#100)
test: add case for unrs#65 (unrs#100)