Comment by TeMPOraL

14 hours ago

> Even to this day Windows has all kinds of problems around long file paths in its ecosystem.

To this day I don't know if it's a Windows problem or a Python problem, because I never encountered this - and never realized this problem exists - except for some random Python code whose docs tell me to set some registry value because of "long paths issue".

The worst offenders I've found are powershell and .Net related stuff.

You can have all the right flags enabled, then unexpectedly you'll run some commandlet and get a path too long error.

Now if your on W11/W25 and the lastest PS it might all work, but W16 and PS versions between now and then had all kinds of things pop up.

It’s a Windows problem. There’s still, to this day, a 259-character limit on path length in the Win32 API unless the OS has been configured to support long paths and the application uses the correct subset of Windows APIs. For example if you use ‘CreateFileA’, you’re stuck with the limit no matter what.

There’s no problem with Python in general. The registry value LongPathsEnabled, which is probably the one you were asked to set, affects the entire Windows system.

However, there’s also an older workaround that allows programs to use “extended paths” even if that setting is off, by prefixing path strings with “\\?\”. So applications using that workaround can use long paths no matter how Windows is configured. But Python doesn’t use the workaround, it uses the modern APIs and if you want long paths, you need to configure the underlying Windows system to enable it.

  • Thanks for the explanation! This is indeed consistent with my observations.

    But it brings me to two follow-up questions:

    1) What is that registry switch even doing, if the problem can be solved with just setting it?

    2) Why is Python not using the workaround like ~everyone else?