Skip to content

fs.writeFileSync doesn't change the mode of existing file. #39859

@gemwuu

Description

@gemwuu

Version

16.4.0

Platform

macOS

Subsystem

Big Sur(11.2.3)

What steps will reproduce the bug?

echo "echo 11" > a && ls -l a && ./a
node -e "fs.writeFileSync('./a', 'echo 1111', {mode: 0o755})" && ls -l a && ./a
-rw-r--r--  1 test  staff  8 Aug 24 19:04 a
a.sh: line 1: ./a: Permission denied
-rw-r--r--  1 test  staff  9 Aug 24 19:04 a
a.sh: line 2: ./a: Permission denied

How often does it reproduce? Is there a required condition?

no condition

What is the expected behavior?

should print 1111.

What do you see instead?

a.sh: line 2: ./a: Permission denied

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to the documentations.fsIssues and PRs related to the fs subsystem / file system.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions