New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Long node_modules paths cannot be found on Windows when LongPathsEnabled
enabled
#50753
Comments
cc: @nodejs/platform-windows |
I took a look at it, but found another issue instead. @karlhorky I forked your repo and the failing run can be found here. I made long path longer, because the original one was shorter then 260 characters. After I did it, Even running Back to the issue you reported, importer uses file URLs internally, thus cannot use |
Thanks for the response, and for the investigation! 🙌
I guess you mean "anything else Node.js-related"? Because the
But maybe the way that GitHub Actions is launching PowerShell + CMD has a problem - maybe a separate GitHub Actions-related problem cc @al-cheb @MaksimZhukov @chrispat:
I'll try to run various commands from a directory with a long path on my Windows machine locally and see what I find. |
Ok, I ran some commands on a Windows 11 Pro x64 machine (both PS C:\> node -v
v20.5.1
PS C:\> mkdir long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\
Directory: C:\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\l
ong-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-p
ath\long-path\long-path\long-path\long-path
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 17.11.2023 16:27 long-path
PS C:\> cd long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\
PS C:\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path> node -v
Program 'node.exe' failed to run: The directory name is invalidAt line:1 char:1
+ node -v
+ ~~~~~~~.
At line:1 char:1
+ node -v
+ ~~~~~~~
+ CategoryInfo : ResourceUnavailable: (:) [], ApplicationFailedException
+ FullyQualifiedErrorId : NativeCommandFailed Commands like PS C:\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path> cd .
PS C:\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path> cmd
Program 'cmd.exe' failed to run: The directory name is invalidAt line:1 char:1
+ cmd
+ ~~~.
At line:1 char:1
+ cmd
+ ~~~
+ CategoryInfo : ResourceUnavailable: (:) [], ApplicationFailedException
+ FullyQualifiedErrorId : NativeCommandFailed Also when running PS C:\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path\long-path> C:\Windows\System32\cmd.exe
Program 'cmd.exe' failed to run: The directory name is invalidAt line:1 char:1
+ C:\Windows\System32\cmd.exe
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~.
At line:1 char:1
+ C:\Windows\System32\cmd.exe
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (:) [], ApplicationFailedException
+ FullyQualifiedErrorId : NativeCommandFailed Wonder if someone from the Windows team involved in interop / this Anyway, back to the import / long path file reading issue, maybe at least this part could be supported by Node.js... |
That is correct. Back to the import with long paths problem. Investigating a bit longer got me to one of my first PRs in this repo, especially to changes in the manifest file. Applying that change solved an issue for me, but I'd like to investigate a bit more to find the root cause. The original PR was dropped in favor of this one as that was enough to fix the issue and something similar should probably be possible here. I'll get back to this later this week to continue my work. |
Regarding the "PowerShell unable to launch programs from long path" problem: I've commented in an existing I may need to open a new issue for this as well. |
After further investigation, I saw that some parts of the code responsible for module loading, do not add the required |
Long paths currently broken on Node.js: nodejs/node#50753
Workaround (for pnpm)
These errors are also caused by the Node.js incompatibility with long paths on Windows. If you're encountering this, one thing you can try is to use
cc @zkochan |
Version
v20.9.0
Platform
Microsoft Windows NT 10.0.20348.0 x64
Subsystem
No response
What steps will reproduce the bug?
I created a reproduction repo at https://github.com/karlhorky/node-js-max_path-windows-bug . The steps in the GitHub Actions workflow file reproduce the bug:
The error that shows up is this:
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
If Windows support for long paths is turned on (see
LongPathsEnabled
check above showing that it's enabled) I would expect Node.js to also support long paths (longer than the Windows ~260 charactersMAX_PATH
limit)What do you see instead?
The crash and error above
Additional information
More information about
LongPathsEnabled
:Context:
I'm here after originally reporting the bug in ESLint (I thought that this comment by @bzoz meant that Node.js is not affected by the 260 character path limit on Windows :
The text was updated successfully, but these errors were encountered: