question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

fs.move fails with chmod error when disk under heavy use

See original GitHub issue

Using fs-extra v2.0.0 I noticed that fs.move, which uses /lib/copy/ncp under the hood, fails with a chmod error when the disk is under heavy use.

{ Error: ENOENT: no such file or directory, chmod '/the/path-a/file'
  errno: -2,
  code: 'ENOENT',
  syscall: 'chmod',
  path: '/the/path-b/file' }

In this case I’m moving a very large directory of a few files. I’m using pify on fs.move:

const binary = (func) => (a, b) => func(a, b)
const move = binary(pify(fs.move))
// ...
move('/the/path-a', '/the/path-b')

With this error on the move operation what ends up happening is that path-a will still exist with one or so of its files left but path-b is created and contains all files (at least it contains a copy of the file remaining in path-a).

Related to #326. \cc @nicks.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:25 (17 by maintainers)

github_iconTop GitHub Comments

2reactions
RyanZimcommented, Feb 21, 2017

@jdalton fs-extra uses fs.rename when possible, if that’s not possible it uses ncp and deletes the source.

@manidlou We don’t use node-mv as a dependency; lib/move/index.js is a fork of node-mv.

@jdalton We don’t want to shell out to mv for a few reasons:

  • child_process is kinda slow
  • It introduces additional cross-platform issues
  • Shelling out is a security issue; without some kind of escaping, malicious filenames could possibly call arbitrary commands on the shell.
0reactions
jprichardsoncommented, Mar 13, 2017

@jdalton thanks for checking back to let us know!! Much appreciated.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node fs Error: EPERM: operation not permitted, open
The issue was that the file was set to readonly (by source control). Unchecking the readonly option in the file properties fixed the...
Read more >
fs-extra - npm
fs -extra contains methods that aren't included in the vanilla Node.js fs package. Such as recursive mkdir, copy, and remove.
Read more >
Troubleshooting Windows Subsystem for Linux | Microsoft Learn
Provides detailed information about common errors and issues people run into while running Linux on the Windows Subsystem for Linux.
Read more >
Windows WSL Ubuntu sees wrong permissions on files in ...
I noticed the owner of the file on Windows was "Administrators". I changed that to be my user following this link and WSL...
Read more >
CHANGELOG.md - ATLAS Open Data
started moving tests inline - upgraded to `jsonfile@2.1.0`, can now pass JSON ... "fs.copy fails with chmod error when disk under heavy use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found