镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

expected behaviour of fs.constants.W_OK #17508

Description

@ahmadnassri
  • Version: tested on 7.x, 8.x, 9.x

according to the documentation:

fs.constants.W_OK - path can be written by the calling process

the description text reads as agnostic to the behaviour of the path existing or not, however in practice, this only works if the path exists:

const fs = require('fs')

fs.access('my-test-file', fs.constants.W_OK, console.log)

results in:

{ Error: ENOENT: no such file or directory, access 'my-test-file'  errno: -2,  code: 'ENOENT',  syscall: 'access',  path: 'my-test-file' }

I am not certain if the intended functionality is what's accurately described, meaning this is a technical bug, or if the description is lacking in clarity.

Happy to help address either through PR, I believe this is a documentation problem, so wanted to be sure before.

Activity

  1. cjihrig commented on Dec 7, 2017

    @cjihrig
    Contributor

    Documentation PR welcome. For inspiration, check out http://man7.org/linux/man-pages/man2/access.2.html. Of specific interest here:

    The mode specifies the accessibility check(s) to be performed, and is either the value F_OK, or a mask consisting of the bitwise OR of one or more of R_OK, W_OK, and X_OK. F_OK tests for the existence of the file. R_OK, W_OK, and X_OK test whether the file exists and grants read, write, and execute permissions, respectively.

  2. ahmadnassri commented on Dec 7, 2017

    @ahmadnassri
    ContributorAuthor

    upon further reading, I believe the issue I'm facing is due checking whether the file path is writable, instead of checking if the file's directory is writable.

    in that context, technically the docs are correct, however, some examples would help.

    I'll take a stab at improving the examples

  3. cjihrig commented on Dec 7, 2017

    @cjihrig
    Contributor

    I'm going to reopen this, because I agree that those docs could be improved. If you or anyone else makes a PR for the docs, then we can close this.

  4. reopened this on Dec 7, 2017
  5. added
    fsIssues and PRs related to file-system APIs and the fs module.
    on Dec 7, 2017
  6. mfaheemakhtar commented on Dec 9, 2017

    @mfaheemakhtar

    Hi, I've tried improving the documentation of fs.access, take a look at my pull request #17578.

    Thanks

  7. gireeshpunathil commented on Apr 28, 2018

    @gireeshpunathil
    Member

    #17578 was never landed but has enough content in for a first timer to pick and progress.

  8. BeniCheni commented on May 1, 2018

    @BeniCheni
    Contributor

    Hi @ gireeshpunathil (edited the comment to say hi to all previous commenters, or issue viewers instead 😅), would you mind if I pick up this first timer? I can work off the content of #17578 and give it a "spin".

  9. gireeshpunathil commented on May 1, 2018

    @gireeshpunathil
    Member

    sure, please go ahead.

  10. added a commit that references this issue on Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    fsIssues and PRs related to file-system APIs and the fs module.good first issueIssues that are suitable for first-time contributors.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions