-
Notifications
You must be signed in to change notification settings - Fork 1k
fs.copyFile and snapshot filesystem #420
Comments
Using ncp as a temporary workaround since it doesn't rely on the |
Another option that works is to use: const fileBuffer = fs.readFileSync(path.resolve(__dirname, 'some_file.json'))
fs.writeFileSync(self.dynLibraryPath, fileBuffer) |
I can confirm your little trick worked out for me o/ |
Maybe pkg does not kidnap function // previously:
function copyFile(sourcePath, targetPath) {
generatedFilePaths.push(targetPath);
fs.copyFileSync(sourcePath, targetPath);
}
// now:
function copyFile(sourcePath, targetPath) {
generatedFilePaths.push(targetPath);
const sourceData = fs.readFileSync(sourcePath, ENCODING);
fs.writeFileSync(targetPath, sourceData, ENCODING);
} |
You need to not use the copy method from the fs-extra package. It must do something with path that pkg intercepts/changes. |
It seems to be a regression bug, since it worked fine until |
This issue is still not solved. Any progress on this issue? @igorklopov |
Hi, @igorklopov thanks for your great work. However, this issue is indeed a pain in our application and still not fixed for two years. Do you have any plans to get this issue to be solved, or suggest some work rounds. Many thanks and wish you a good day. |
We workaround this issue by loading the following patch at beginning of the main module: https://github.com/serverless/serverless/blob/94ff3b22ab13afc60fb4e672520b4db527ee0432/lib/utils/standalone-patch.js |
this work with pkg 4.4.9 |
This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this issue entirely you can add the no-stale label |
. |
bump, cant copy file from snapshot |
It is really annoying bug. Why is not it getting fixed? |
This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this issue entirely you can add the no-stale label |
bump |
This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this issue entirely you can add the no-stale label |
. |
Hi everyone, I use pkg like you for my projects and when I find a bug I try to fix it my self, fixing this is not so difficult as it just require to add a patch like the one specified by @medikoo in Please if you use this project help to keep it maintained by contributing to it. Thanks |
PR ready to fix this |
@robertsLando I like it, i think the only thing is that it may lead people to not understand context when working with this package. If they inadvertently forget to include a file in the snapshot and it loads a file from the filesystem instead it could cause some issues or in a worst case scenario a vulnerability. I think that's why this hasn't been patched/implemented. |
@jdziat IMO the patch should be integrated to bootstrap as lot users are having this issue |
@robertsLando Not disagreeing but you may want to make it possible to turn this off via a flag. |
bump |
Trying to copy a file from the snapshot filesystem to the real filesystem results in the following error:
ENOENT: no such file or directory
. Seems to happen in all versions after 4.2.4.Example code that should work:
The text was updated successfully, but these errors were encountered: