Skip to content

fs.mkdir recursive edge case potential issues #25110

Description

@coreyfarrell
  • Version: v10.14.2
  • Platform: Linux lt2 4.19.8-200.fc28.x86_64 deps: update openssl to 1.0.1j #1 SMP Mon Dec 10 15:43:40 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
  • Subsystem: fs

Example Code:

const fs = require('fs');
fs.mkdirSync('/', {recursive: true, mode: 0o777});
  • In Windows this results in an EPERM exception.
  • On my Linux system this does not attempt to chmod the existing path, it reports success as the path already exists even though the mode is wrong.

The same occurs with fs.mkdir, I used fs.mkdirSync in the example as the code is simpler.

I've uncovered these edge cases via sindresorhus/make-dir#7 where I'm working on making that module use the native recursive mkdir when possible. The plan is for make-dir@2 to emulate the native fs.mkdir recursive for older versions of node, so I'm hoping for clarification on these two potential issues.

CC @bcoe

Metadata

Metadata

Assignees

Labels

fsIssues and PRs related to file-system APIs and the fs module.windowsIssues and PRs related to the Windows platform.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions