Closed aleen42 closed 2 years ago
Right, this looks to be because getuid
isn't actually present - it doesn't look like we're using it ourselves though.
It's debatable where the bug actually lies: us shiming getuid
by itself is not an issue, but gulp
must be seeing that and assumes it's on Linux
https://gulpjs.com/docs/en/api/dest/#metadata-updates:
Whenever the dest() stream creates a file, the Vinyl object's mode, mtime, and atime are compared to the created file. If they differ, the created file will be updated to reflect the Vinyl object's metadata. If those properties are the same, or gulp doesn't have permissions to make changes, the attempt is skipped silently.
This functionality is disabled on Windows or other operating systems that don't support Node's process.getuid() or process.geteuid() methods. This is due to Windows having unexpected results through usage of fs.fchmod() and fs.futimes().
It looks like we're using that method here: https://github.com/streamich/memfs/blob/8523ceca916918d0cfe324766ce9c1a07f0a650e/src/node.ts#L20
It could be argued that removing our polyfill is a breaking change, but it's not something we advertise as being a feature (rather it's an internal fallback for us) so we could probably replace it with process.getuid?.() ?? 0
🤔
Yes, do not modify the method directly is always a better practice. What memfs
needs is to just avoid the NPE exception when accessing process.getuid()
in Windows.
PRs are always welcome :)
:tada: This issue has been resolved in version 3.4.7 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
Recently I have found that when I imported
memfs/lib/process.js
and usedgulp
to copy a directory with a subdirectory, I got an errorError: EPERM: operation not permitted, futime
.Here is the snippet to show how to reproduce the problem:
It seems that it is a mocked
uid
resulting in side effects when trying tofutime
.The temporary workaround is to revert it within the current process: