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

writeFileSync may error with cross-device link not permitted on Windows #71

Open
davidmurdoch opened this issue Oct 12, 2020 · 1 comment

Comments

@davidmurdoch
Copy link

davidmurdoch commented Oct 12, 2020

Windows apps installed via .appx may be installed to any drive the user chooses. From what I understand, when an appx application is executed, the file system is virtualized; Windows lies to the application about where it is running from, and when the application accesses a file, Windows proxies the calls across from the virtualized location to the actual location.

Example: if Windows is installed on C:, I can install an AppX application on D:. When the application is launched, Windows will the application CWD will be C:\Users\David\AppData\Roaming\{AppName} instead of somewhere on the D: drive.

(note: I could be wrong about what Windows is really doing here!)

All that to say... the following call to fs.renameSync may fail with a cross-device link not permitted error. I wish Windows would handle this internally, as this really seems more like a Windows bug than bug in write-file-atomic to me.

fs.renameSync(tmpfile, filename)

A potential solution may be to first try the rename, then try a copy + delete operation if that rename fails.

related issue: trufflesuite/ganache-ui#1943

@tonyxiao
Copy link

tonyxiao commented Jul 5, 2022

This also happens on macOS if you have separate volumes

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

No branches or pull requests

2 participants