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
ENAMETOOLONG error when running prettier #16115
Comments
@Anu48 think this is a system issue. |
The error message that's in the logs:
This suggests that someone tried to use a shell glob syntax in a setting that doesn't automatically expand shell globs. Syntax like
This action appears to be executing something like:
This is a single file, where the file name is around 304 characters long (way too long for most filesystems) and the full path name is around 367 characters (which should be fine). It does not identify seven files or eight files. It identifies one file with a name so long that it cannot exist. (If the first form actually works, then this suggests that This line in the workflow file looks very suspect:
I strongly recommend that this workflow file, in its current form, should be abandoned. Re-write the file without using Thanks |
The first form worked for the smaller glob as seen in the earlier step (Run prettier (7)) The Here's prettier w/ 7: Thu, 25 Apr 2024 22:26:33 GMT
[pid 1720] statx(AT_FDCWD, "/home/runner/work/prettier-enametoolong/prettier-enametoolong/{a.json,aa.json,aaaa.json,aaaaaaaa.json,aaaaaaaaaaaaaaaa.json,aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json,aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json}", AT_STATX_SYNC_AS_STAT|AT_SYMLINK_NOFOLLOW, STATX_ALL, <unfinished ...>
Thu, 25 Apr 2024 22:26:33 GMT
[pid 1710] epoll_wait(13, <unfinished ...>
Thu, 25 Apr 2024 22:26:33 GMT
[pid 1720] <... statx resumed>0x7fb38effdb40) = -1 ENOENT (No such file or directory) Here's prettier w/ 8: Thu, 25 Apr 2024 22:26:34 GMT
[pid 1766] statx(AT_FDCWD, "/home/runner/work/prettier-enametoolong/prettier-enametoolong/{a.json,aa.json,aaaa.json,aaaaaaaa.json,aaaaaaaaaaaaaaaa.json,aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json,aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json,aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json}", AT_STATX_SYNC_AS_STAT|AT_SYMLINK_NOFOLLOW, STATX_ALL, <unfinished ...>
Thu, 25 Apr 2024 22:26:34 GMT
[pid 1756] epoll_wait(13, <unfinished ...>
Thu, 25 Apr 2024 22:26:34 GMT
[pid 1766] <... statx resumed>0x7f5358ffbb40) = -1 ENAMETOOLONG (File name too long) Let's talk about what prettier is actually doing to get here... Line 322 in 1264a4c
which calls prettier/src/cli/expand-patterns.js Line 15 in 1264a4c
which calls lstatSafe : prettier/src/cli/expand-patterns.js Line 70 in 1264a4c
which calls lstat :Lines 76 to 82 in 1264a4c
Here's a simple node script derived from prettier's lstat code to show what's happening: > const { default: fs } = await import("node:fs/promises");
> await fs.lstat('/tmp/x/a.json')
Stats {
dev: 41,
mode: 33188,
nlink: 1,
uid: 0,
gid: 0,
rdev: 0,
blksize: 4096,
ino: 1732665,
size: 0,
blocks: 0,
atimeMs: 1714085698490.0015,
mtimeMs: 1714085698490.0015,
ctimeMs: 1714085698490.0015,
birthtimeMs: 1714085698490.0015,
atime: 2024-04-25T22:54:58.490Z,
mtime: 2024-04-25T22:54:58.490Z,
ctime: 2024-04-25T22:54:58.490Z,
birthtime: 2024-04-25T22:54:58.490Z
}
> await fs.lstat('/tmp/x/{a.json,aa.json}')
Uncaught Error: ENOENT: no such file or directory, lstat '/tmp/x/{a.json,aa.json}'
at async Object.lstat (node:internal/fs/promises:1018:18)
at async REPL24:1:33 {
errno: -2,
code: 'ENOENT',
syscall: 'lstat',
path: '/tmp/x/{a.json,aa.json}'
}
> await fs.lstat('/tmp/x/{a.json,aa.json,aaaa.json,aaaaaaaa.json,aaaaaaaaaaaaaaaa.json,aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json,aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json,aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json}')
Uncaught:
Error: ENAMETOOLONG: name too long, lstat '/tmp/x/{a.json,aa.json,aaaa.json,aaaaaaaa.json,aaaaaaaaaaaaaaaa.json,aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json,aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json,aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json}'
at async Object.lstat (node:internal/fs/promises:1018:18)
at async REPL25:1:33 {
errno: -36,
code: 'ENAMETOOLONG',
syscall: 'lstat',
path: '/tmp/x/{a.json,aa.json,aaaa.json,aaaaaaaa.json,aaaaaaaaaaaaaaaa.json,aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json,aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json,aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json}'
} As we can see from the basic node calls, So, all we need to do to make this code friendlier is to handle it in the same manner. |
Well, I'm very glad that prettier isn't going through the shell to do this, but it seems very strange and unusual to me all the same. But, if handling arguments as globs transparently is actually a desired feature, then yeah, it'd be worth handling |
Environments:
Steps to reproduce:
See the following action run: https://github.com/Anu48/prettier-enametoolong/actions/runs/8021903284/job/21915048683
We create a couple of files where each file name doubles in character.
Keep a close eye on the 'Prettier (7)' step vs 'Prettier (8)' step.
'Prettier (7)' and Prettier (8)' steps runs yarn prettier. But 'Prettier (7)' step runs yarn prettier on the first 7 files and 'Prettier (8)' step runs yarn prettier on the first 8 files.
Look into the github summary step to see how 'Prettier (7)' step and 'Prettier (8)' processes the files.
Expected behavior:
Running prettier on a spec containing the first 8 files should result to the same behaviour as running prettier on a spec containing 7 files
Actual behavior:
When running prettier on a spec containing 8 files, it results to an ENAMETOOLONG error. It should be consistent with the behaviour found when running prettier with 7 files
The text was updated successfully, but these errors were encountered: