Skip to content

EACCES when renaming folder that is being watched from nodejs #3395

@alexdima

Description

@alexdima

Microsoft Windows [Version 10.0.17134.112]

I am trying to use chokidar, a popular nodejs file system watcher library.

Whenever I use chokidar to listen for file system changes, I can no longer rename folders that lie within the folder being watched.

  • npm install chokidar
  • mkdir test
  • echo hello > test/test.txt
  • create repro.js:
var fs = require('fs');
var chokidar = require('chokidar');

// Watch current directory and ignore the node_modules folder
chokidar.watch('.', {ignored: /node_modules/}).on('all', (event, path) => {
  console.log(event, path);
});

// After sufficient time, attempt to rename the test folder
// Note: this is also reproducible using `mv` on the command line
setTimeout(function() {
    fs.rename('test', 'test2', function(err) {
        if (err) {
            console.log(err);
        } else {
            console.log('rename ok');
        }
    });
}, 1000);

WSL (Ubuntu 18.04):
image

Ubuntu 18.04:
image

I don't think it is terribly important (other colleagues are able to reproduce with other node versions), but I am using nodejs v8.11.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions