Skip to content
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

ENOENT: no such file or directory -4058 - Path exceeds 256 characters #83

Open
gabrown13 opened this issue Feb 9, 2021 · 1 comment

Comments

@gabrown13
Copy link

When running the scan with the following command line, "electronegativity -i d:<pathToSource>" I received the error "[Error: ENOENT: no such file or directory, stat 'D:...
{
errorno: -4058
code: 'ENOENT'
syscall: 'stat',
path: 'D:\...
}

The problem is not that the file is missing, it is that the DOS path exceeds 256 characters and the folders and file names beyond the 256 limit are not recognized.

To Reproduce

  1. On a Windows 10 Machine create a folder structure that will exceed 256 characters
  2. Check out a project to scan in that folder path.
  3. From the command prompt run the command electronegativity -i <d:\LongPathToProject>
  4. This should reproduce the error.

Expected behavior
Most modern OSs do not have a restriction on the number of character for the filename and folder structure. My expectation was that the scan would have completed and not reported that a file was missing.

**Stacktraces **
See above error message.

Platform (please complete the following information):

  • OS: [Windows 10]
  • Electronegativity version: v1.7.0
@LoganDark
Copy link

LoganDark commented Jan 31, 2022

Most modern OSs do not have a restriction on the number of character for the filename and folder structure.

Except Windows does and that's where the issue lies. Windows is very much not a "modern" OS as most of it is decades old by this point. Microsoft keeps giving it new coats of paint, but it's still the same old NT codebase underneath, which borrows a lot from DOS. You seem to already know this as you've deduced that it has to do with "DOS paths" being longer than 255 characters.

There is a way to get around "DOS paths". Windows has a method for bypassing the max path length limit by representing paths in a different way (I believe they're called extended paths, or UNC paths, or something like that). However I think electronegativity has to do this manually.

Luckily it's as simple as replacing your boring old C:\Users\Whatever\Documents\Project with \\?\C:\Users\Whatever\Documents\Project as documented here. I believe it might actually work if you pass a path starting with \\?\ to electronegativity.

If that doesn't work, for now you can use WSL which doesn't have such a low path length limit.

EDIT: Interesting, it appears Windows 10 versions later than 1607 have the ability to disable the max path length limitation altogether. That would almost certainly solve the problem on your machine. Actually reading further it seems like this only works for applications that also opt-in to this behavior. Dang.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants