-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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 |
Fixes: #50753 PR-URL: #51097 Reviewed-By: Joyee Cheung <[email protected]>
It looks like the Node.js v22 PR contains the fix "module,win: fix long path resolve (by @StefanStojanovic) #51097": So maybe Node.js has support for long paths on Windows now! (make sure that you have |
@StefanStojanovic thanks for the PR btw, excited for this to be eventually fixed! I just upgraded to Node.js 22.1.0 in my reproduction repo in the PR below: However, the test run of the GitHub Actions workflow still failed: Run (Get-ItemProperty "HKLM:System\CurrentControlSet\Control\FileSystem").LongPathsEnabled
1
Run actions/setup-node@v4
Attempting to download >=22.1.0...
Not found in manifest. Falling back to download directly from Node
Acquiring 22.1.0 - x64 from https://nodejs.org/dist/v22.1.0/node-v22.1.0-win-x64.7z
Extracting ...
Adding to the cache ...
Done
Environment details
node: v22.1.0
npm: 10.7.0
yarn: 1.22.22
$ node eslint.config.js
node:internal/modules/run_main:125
triggerUncaughtException(
^
Error: Cannot find package 'D:\a\node-js-max_path-windows-bug\node-js-max_path-windows-bug\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_modules\eslint-plugin-import\package.json' imported from D:\a\node-js-max_path-windows-bug\node-js-max_path-windows-bug\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\eslint.config.js
Did you mean to import "eslint-plugin-import/lib/index.js"?
at legacyMainResolve (node:internal/modules/esm/resolve:214:26)
at packageResolve (node:internal/modules/esm/resolve:832:14)
at moduleResolve (node:internal/modules/esm/resolve:918:18)
at defaultResolve (node:internal/modules/esm/resolve:1148:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:541:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:510:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:240:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49) {
code: 'ERR_MODULE_NOT_FOUND'
}
Node.js v22.1.0
Error: Process completed with exit code 1. Here's the file it's running (this file runs fine in a location in a shorter path): import eslintImport from 'eslint-plugin-import';
const config = [
{
plugins: {
import: eslintImport,
},
rules: {
'no-unused-vars': 'warn',
},
},
];
export default config; Is there still a bug here? Maybe this issue should be reopened? |
Friendly ping @StefanStojanovic - should this issue be reopened? (I could also open a new issue, but would like to avoid that duplication if possible) |
I was out of the office last week. Thanks for bringing this to my attention again. I'm working on some other things now, but I'll take a look once I have some free cycles. |
Great, thanks! Is it possible to reopen the issue too? To keep it on the radar? |
@StefanStojanovic Or I can open another issue with the same issue description and title and link it to this one, if that's better... |
@karlhorky we can do it both ways. I do not have time to work on this now, but I've talked to my colleague @huseyinacacak-janea and he'll take a look. In my PR that addressed this issue, I added a new test |
Ok great, thanks for the info! I see the current version of the test at node/test/es-module/test-GH-50753.js Lines 1 to 42 in 2aaeaa8
Current version looks good, but low-level (whereas my reproduction was more on the "end to end" / "integration" end of the spectrum) - maybe there is something else in Node.js that is also failing... 🤔 |
@huseyinacacak-janea could you reopen this issue as a tracking issue for this work? |
Oh, apparently @huseyinacacak-janea doesn't have access to reopen the issue @StefanStojanovic could you do it instead? |
Can it be merged into other TLC versions? |
PR-URL: #53294 Fixes: #50753 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]>
PR-URL: #53294 Fixes: #50753 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]>
@huseyinacacak-janea thanks for the PR fixing the problem in #53294, and thanks @RafaelGSS and other Node.js contributors for the Node.js 22.7.0 release PR #54452 where the fix landed I just upgraded to Node.js 22.7.0 in my reproduction repo in the PR below: I can confirm that the workflow run of the GitHub Actions workflow was successful 🎉 So for my reproduction case, this is now resolved 🙌 If there are any other further long path issues with Node.js on Windows, I'll be sure to open a different issue and mention it here (if the issue is not locked over time). |
I tried to follow this fix, and it seemed to work. However, trying longer paths still causes this to fail. In your example, the path length is still below 260. If you try creating a path that is longer than 260 and |
@ibrahimqasim-abtrace I have not noticed any failures, but it's possible that I'm not testing the same way you mean. Can you fork my repo and create a reproduction that fails on GitHub Actions? https://github.com/karlhorky/node-js-max_path-windows-bug Then it will be a clear, reproducible failure that Node.js can look at. |
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: