Long file path issues in Windows 11 Pro with Microsoft VS Code and File Explorer

Anonymous
2022-05-04T22:27:47+00:00

I spent way too long debugging a compile error in MS VS Code (64bit version 1.66.2). It would fail with 'file not found' or 'unable to access file' errors. The workspace is located in "C:\Users\UserName\Documents\My Workspaces\firmware", with several levels of nested source folders below.

Initially, I got several linking errors due to Controlled Folder Access protection using the Ransomware protection built-in to Windows Security. I whitelisted ar.exe and as. exe, but the errors persisted. I even turned off Ransomware protection. Seeing a thread online about long file paths reminded me I hadn't enabled that on Windows 11 yet (fresh install), so I changed the following settings and rebooted the PC:
Registry: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled set to 1.

Group Policy: System "Configuration>Administrative Templates>System>Filesystem>Enable Win32 long paths" enabled.

About that time I noticed an issue with not being able to delete or rename files on an SMB share that were in a deep path. If I went to the other system and moved them up a few folders I was again able to rename the files.

Both of these scenarios work fine from my Windows 10 Pro PC. My Windows 11 Pro PC is a fresh install (Version 21H2 Build 22000.613).

So I believe Windows 11 isn't respecting my Long Paths settings. As a final test, I moved my VS Code Workspace folder to system drive root (C:\firmware) and it compiled without error.

I've seen other questions on here about Windows 11 path length issues that were brushed away because they were encountered using non-Microsoft 3rd Party software, but this is all built-in File Explorer and Microsoft's own VS Code product.

My question is, how do I actually allow long file paths in Windows 11 Pro?

Windows for home | Windows 11 | Files, folders, and storage

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

77 answers

Sort by: Newest
  1. Anonymous
    2023-01-13T16:48:54+00:00

    I'm amazed this is broken, even on Windows 11 pro 22H2

    It worked fine on my last Windows 10 pro machine

    Setting with regedit: BROKEN

    Setting with group policy: BROKEN

    Setting with M365 configuration: BROKEN

    It should be on by default!

    And it should work...

    Was this answer helpful?

    5 people found this answer helpful.
    0 comments No comments
  2. Anonymous
    2023-01-13T02:47:57+00:00

    I have an update from Microsoft! But, you're not going to like it....

    They told me to try that Group Policy thing:

    "Can you please check with the Group Policy for the long path enabled, which is present over

    System Configuration>Administration Template>System>File System then please select enable longs path to open it."

    But, the good news, they also said: "We have checked the same at our end and it's having the same scenario."

    So, it's possible that they've reproduced the issue. I've asked for clarification, and pointed out that the group policy thing didn't work.

    It's unfortunate that the VM I ran their logging stuff on used the registry setting trick to enable long path support. Turns out that if you go with the group policy trick then that'll also set the registry key, but not vice versa.

    Maybe they'll get back to me in another 6 weeks with a new update. Wow, it's been 6 weeks!

    Was this answer helpful?

    3 people found this answer helpful.
    0 comments No comments
  3. Anonymous
    2022-12-28T16:25:39+00:00

    You're using a console window instead of a ISE power shell. For console windows use \ instead of /

    Once I ran into the windows 11 issues with my application I ended up reproducing the issue with emoji/unicode strings, and the ISE powershell supports those way better than the console. FYI: unicode chars can eat into the 255 byte limit really quickly.

    I have no idea why I was using forward slashes, they cause all sorts of problems. Sorry about that.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2022-12-28T13:09:14+00:00

    Thanks for your reply.

    I get this error from the first line of the suggested script:

    The syntax of the command is incorrect.

    And I get this error from each subsequent line of the suggested script:

    The system cannot find the path specified.

    Was this answer helpful?

    0 comments No comments
  5. Anonymous
    2022-12-22T16:27:29+00:00

    each folder can only be up to about 256ish bytes. Same limit for the filename part.

    Try this script to test your windows 10 box:

    md ./o123456789o123456789o123456789o123456789o123456789o123456789o123456789o123456789o1234_ThisIs100bytes

    cd ./o123456789o123456789o123456789o123456789o123456789o123456789o123456789o123456789o1234_ThisIs100bytes

    md ./o123456789o123456789o123456789o123456789o123456789o123456789o123456789o123456789o1234_ThisIs200bytes

    cd ./o123456789o123456789o123456789o123456789o123456789o123456789o123456789o123456789o1234_ThisIs200bytes

    md ./o123456789o123456789o123456789o123456789o123456789o123456789o123456789o123456789o1234_ThisIs300bytes

    cd ./o123456789o123456789o123456789o123456789o123456789o123456789o123456789o123456789o1234_ThisIs300bytes

    md ./o123456789o123456789o123456789o123456789o123456789o123456789o123456789o123456789o1234_ThisIs400bytes

    cd ./o123456789o123456789o123456789o123456789o123456789o123456789o123456789o123456789o1234_ThisIs400bytes

    Windows 11 fails to make the 300byte folder

    Was this answer helpful?

    2 people found this answer helpful.
    0 comments No comments