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

Behavior of realpath with an empty string argument #53635

Description

@avivkeller

Refs: #35403

Currently, the project has 2 outcomes for different realpath functions with empty string arguments:

fs.realpathSync('') // Returns CWD
await util.promisify(fs.realpath)('') // Returns CWD

await fs.promises.realpath('') // ENOENT Error
fs.realpathSync.native('') // ENOENT Error
await util.promisify(fs.realpath.native)('') // ENOENT Error

IMO, this should be standardized to
(A) Always throw
(B) Always return CWD
(C) Return CWD for non-.native calls, throw otherwise

Activity

  1. added
    fsIssues and PRs related to file-system APIs and the fs module.
    discussIssues opened for discussion and feedback.
    on Jun 28, 2024
  2. richardlau commented on Jun 28, 2024

    @richardlau
    Member

    There is always going to be a discrepency between fs.realpath() and fs.promises.realpath().

    For some history fs.realpath() and fs.realpathSync() differ from native realpath and have behaviour oddities that were too breaking to change. At one point it was changed to call the native realpath but there were a number of issues that resulted in the implementation being reverted, see #7726.

    When fs.promises.realpath() was added the decision was made to call the native realpath since it was a new API and be consistent with fs.realpath.native().

  3. avivkeller commented on Jun 28, 2024

    @avivkeller
    MemberAuthor

    I'm aware that there historically have been discrepency, but I think that the discrepencies (for errors) should be handled, or noted in the docs.

  4. github-actions commented on May 8, 2026

    @github-actions
    Contributor

    This issue has been marked as stale due to 210 days of inactivity.
    It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.

  5. added
    staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.
    on May 8, 2026
  6. github-actions commented on Jun 7, 2026

    @github-actions
    Contributor

    This issue has been automatically closed after 30 days of inactivity following its stale status (no activity for a total of 240 days).
    If this is still relevant, feel free to reopen it or leave a comment with additional details so we can continue the discussion.

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

    discussIssues opened for discussion and feedback.fsIssues and PRs related to file-system APIs and the fs module.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions