-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Description
What happened?
the fix for #1206 is not robust enough because having the same drive letter is not sufficient to establish that two paths are on the same harddrive.
The reason is that NTFS allows mounting partitions to any empty NTFS folder, basically just like linux mount. One way to do that is through Disk Management (diskmgmt.msc) (https://www.windowscentral.com/how-mount-hard-drive-folder-windows-10). For example here I mounted my D: to ~/Desktop/D:
(Remarks: A direct implication here is that there's no guarantee all partitions have drive letters. Here I can just remove the D drive letter designation, then I would only be able to access this partition through the mounted folder, and that's perfectly legal in Windows.)
Now try
fs.renameSync('~/Desktop/whatever '~/Desktop/D/whatever');
and you'll still get EXDEV, even when the source and destination have the same drive letter.
Another way to trigger this is when you use Docker Windows containers and mount docker volumes. Run a container from windows nanoserver image and mount a volume through docker run -v volume:C:\mounted. Now C:\mounted has drive letter C but trying to rename into it will still trigger EXDEV.
What did you expect to happen?
The correct way to do
nvm-windows/src/utility/rename.go
Line 10 in 83a18bb
| func Rename(old, new string) error { |
err := os.Rename(old, new)
if err == nil {
return nil
}
DebugLogf("rename failed: %w, fallback to copy", err)
// If old is a directory, copy recursively
...
Version
1.2.2