Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

fs.copyFile() does not work with /snapshot paths #639

Closed
TooTallNate opened this issue Feb 26, 2019 · 17 comments · Fixed by #1484
Closed

fs.copyFile() does not work with /snapshot paths #639

TooTallNate opened this issue Feb 26, 2019 · 17 comments · Fixed by #1484
Assignees
Labels

Comments

@TooTallNate
Copy link
Member

TooTallNate commented Feb 26, 2019

https://nodejs.org/api/fs.html#fs_fs_copyfile_src_dest_flags_callback

Example error:

{ Error: ENOENT: no such file or directory, copyfile '/snapshot/foo/bar/index.js.map' -> '/Cache/foo/bar/index.js.map'
  errno: -2,
  code: 'ENOENT',
  syscall: 'copyfile',
  path: '/snapshot/foo/bar/index.js.map',
  dest: '/Cache/foo/bar/index.js.map' }
TooTallNate added a commit to vercel/fun that referenced this issue Feb 27, 2019
Until vercel/pkg#639 is resolved, we have to
implement the `copy()` operation without relying on `fs.copyFile()`.
@jingsam
Copy link

jingsam commented Sep 1, 2019

I encounter same issue when use fs-extra copySync function. pkg 4.2.6 work fine.

@timsuchanek
Copy link

We have the same issue for the prisma CLI.

@github-actions
Copy link

github-actions bot commented Apr 7, 2021

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

@github-actions github-actions bot added the Stale label Apr 7, 2021
@github-actions
Copy link

This issue is now closed due to inactivity, you can of course reopen or reference this issue if you see fit.

@jingsam
Copy link

jingsam commented Apr 12, 2021

ops! This issue does't resolve yet

@kamesh95
Copy link

kamesh95 commented Jun 25, 2021

@TooTallNate Is there an update on this issue or any workaround? I am still facing this in pkg v5.2.1

@kamesh95
Copy link

The same thing happens when using chmod function as well. It says:

ENOENT: no such file or directory, chmod [[PATH_TO_FILE]]

I checked the path using exists function and it returned true that file does exist. But in chmod the same path fails as ENOENT

console.warn("exists:::", fse.existsSync(SCRIPT_PATH));
fse.chmodSync(SCRIPT_PATH, "755");

Output of above lines:

exists::: true
Exception:  
ENOENT: no such file or directory, chmod [[SCRIPT_PATH]]

@github-actions
Copy link

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

@github-actions github-actions bot added the Stale label Sep 27, 2021
@jingsam
Copy link

jingsam commented Sep 27, 2021

bump

@robertsLando
Copy link
Contributor

robertsLando commented Sep 29, 2021

It could be because, like for other fs methods, it should be overriden: https://github.com/vercel/pkg/blob/main/prelude/bootstrap.js#L975

And defined here: https://github.com/vercel/pkg/blob/main/prelude/bootstrap.js#L502

@github-actions
Copy link

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

@github-actions github-actions bot added the Stale label Dec 29, 2021
@jingsam
Copy link

jingsam commented Dec 29, 2021

.

@robertsLando
Copy link
Contributor

@jingsam PR?

@AzazelloB
Copy link

The workaround

async function copy(source, target) {
    // use stream pipe to reduce memory usage
    // when loading a large file into memory.
    const writeFileStream = fs.createWriteStream(target);
    const readFileStream = fs.createReadStream(source).pipe(writeFileStream);

    return new Promise(function(resolve, reject) {
        writeFileStream.on('finish', resolve);
        readFileStream.on('error', reject);
    });
}

@AzazelloB
Copy link

@jingsam ^

@robertsLando
Copy link
Contributor

I already opened a pr to fix this: #1484

@robertsLando robertsLando linked a pull request Jan 20, 2022 that will close this issue
@jesec
Copy link
Contributor

jesec commented Jan 28, 2022

dupe of #420.

@jesec jesec closed this as completed Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants