FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

win: fix fs.realpath.native for long paths by StefanStojanovic · Pull Request #44536 · nodejs/node · GitHub

/ node Public

win: fix fs.realpath.native for long paths - #44536

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
JaneaSystems:mefi-realpath-longpath
Sep 13, 2022
Merged

win: fix fs.realpath.native for long paths#44536
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
JaneaSystems:mefi-realpath-longpath

Conversation

Copy link
Copy Markdown
Contributor

On windows when using fs.realpath.native, fs.realpathSync.native and fs.promises.realpath on long path, ENOENT is thrown. On the other hand, long paths work well with fs.realpath and fs.realpathSync. On Linux, all of the mentioned realpath versions work as expected.

The problem is that windows API functions do not work with paths longer then 260 characters by default. There is a way to enable long path support via application manifest file, but it only works starting from Windows 10 version 1607 and it relies on registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled being set. Since that is not necessarily always the case with machines running node, this approach wouldn't work. The other way to enable working with long paths is to add a \\?\ prefix to the path prior to using it in windows API functions. This approach is used by all fs functions working with paths, with the exception of fs.realpath.native and fs.realpathSync.native.

Fix is made in fs.js implementation of fs.realpath.native, fs.realpathSync.native, so their path preprocessing matches to the other functions.

An existing windows long path test is improved to cover the issue that is fixed by these changes.

Fixes: #39721

Unlike other fs.js functions that work with paths, realpath.native isn't
using pathModule.toNamespacedPath prior to calling libuv function. This
is causing issues on windows.

Windows long path test is also improved to cover the mentioned issue.

Fixes: nodejs#39721
nodejs-github-bot added fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. labels Sep 6, 2022
lpinca added the request-ci Add this label to start a Jenkins CI on a PR. label Sep 6, 2022
github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Sep 6, 2022

This comment was marked as outdated.

lpinca commented Sep 6, 2022
edited
Loading

Copy link
Copy Markdown
Member

Supersedes #44522.

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/46468/

Copy link
Copy Markdown
Contributor Author

Hello everyone, is there anything else I can do to help move this forward?

Flarna added commit-queue Add this label to land a pull request using GitHub Actions. author ready PRs that have at least one approval, no outstanding review comments, and a CI started. and removed needs-ci PRs that need a full CI run. labels Sep 13, 2022
nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Sep 13, 2022
nodejs-github-bot merged commit 8b50160 into nodejs:main Sep 13, 2022

Copy link
Copy Markdown
Collaborator

Landed in 8b50160

RafaelGSS pushed a commit that referenced this pull request Sep 26, 2022
Unlike other fs.js functions that work with paths, realpath.native isn't
using pathModule.toNamespacedPath prior to calling libuv function. This
is causing issues on windows.

Windows long path test is also improved to cover the mentioned issue.

Fixes: #39721
PR-URL: #44536
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
RafaelGSS mentioned this pull request Sep 26, 2022
RafaelGSS pushed a commit that referenced this pull request Sep 26, 2022
Unlike other fs.js functions that work with paths, realpath.native isn't
using pathModule.toNamespacedPath prior to calling libuv function. This
is causing issues on windows.

Windows long path test is also improved to cover the mentioned issue.

Fixes: #39721
PR-URL: #44536
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
juanarbol mentioned this pull request Oct 4, 2022
juanarbol pushed a commit that referenced this pull request Oct 4, 2022
Unlike other fs.js functions that work with paths, realpath.native isn't
using pathModule.toNamespacedPath prior to calling libuv function. This
is causing issues on windows.

Windows long path test is also improved to cover the mentioned issue.

Fixes: #39721
PR-URL: #44536
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
juanarbol pushed a commit that referenced this pull request Oct 7, 2022
Unlike other fs.js functions that work with paths, realpath.native isn't
using pathModule.toNamespacedPath prior to calling libuv function. This
is causing issues on windows.

Windows long path test is also improved to cover the mentioned issue.

Fixes: #39721
PR-URL: #44536
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
juanarbol pushed a commit that referenced this pull request Oct 11, 2022
Unlike other fs.js functions that work with paths, realpath.native isn't
using pathModule.toNamespacedPath prior to calling libuv function. This
is causing issues on windows.

Windows long path test is also improved to cover the mentioned issue.

Fixes: #39721
PR-URL: #44536
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
guangwong pushed a commit to noslate-project/node that referenced this pull request Jan 3, 2023
Unlike other fs.js functions that work with paths, realpath.native isn't
using pathModule.toNamespacedPath prior to calling libuv function. This
is causing issues on windows.

Windows long path test is also improved to cover the mentioned issue.

Fixes: nodejs/node#39721
PR-URL: nodejs/node#44536
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
guangwong pushed a commit to noslate-project/node that referenced this pull request Jan 3, 2023
Unlike other fs.js functions that work with paths, realpath.native isn't
using pathModule.toNamespacedPath prior to calling libuv function. This
is causing issues on windows.

Windows long path test is also improved to cover the mentioned issue.

Fixes: nodejs/node#39721
PR-URL: nodejs/node#44536
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no outstanding review comments, and a CI started. fs Issues and PRs related to the fs subsystem / file system.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fs.promises.realpath throws ENOENT on long paths on Windows, while the realpathSync version works for the same paths

4 participants


Back | FazBrowse Home | New Git URL