jprichardson / node-fs-extra

Node.js: extra methods for the fs object like copy(), remove(), mkdirs()
MIT License
9.44k stars 776 forks source link

Error: Cannot copy 'Source Directory' to a subdirectory of itself, 'Destination directory' when run with nexe. #944

Closed hnviradiya closed 2 years ago

hnviradiya commented 2 years ago

if we use "fs-extra"'s copySync method. It gives source and destincation stat same in fs-extra.

Error: Cannot copy 'Source Directory' to a subdirectory of itself, 'Destination directory'

Following is the line where "areIdentical" is getting to true when run inside nexe. But gives different without nexe.

https://github.com/jprichardson/node-fs-extra/blob/69eb8964626871000de3a95548cd36035b5c4b27/lib/util/stat.js#L120

This issue only occurs when built with nexe. if we run without nexe it works fine.

OS: windows 11 NodeJs Version: v16.14.0 fs-extra: 10.0.0

I have also logged issue on nexe and found that they are faking the device id. so stats are getting same.

But as I have also passed { overwrite: true }, it should still replace the file right to destination?

RyanZim commented 2 years ago

No, overwrite won't help here. You fundamentally can't copy to a subdirectory without an infinite loop. Of course, it's not actually a subdirectory; it's just nexe's bad data here. Unfortunately, I don't know of anything to do other than waiting for nexe to fix the issue.