Path too long: Filename too long / Windows Long Path support
A file path is longer than the classic Windows limit of 260 characters.
The message
error: unable to create file …: Filename too long | ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: '…' HINT: This error might have occurred since this system does not have Windows Long Path support enabled.
Affects: Git for Windows, Python, ComfyUI, AUTOMATIC1111 Stable Diffusion WebUI, Stable Diffusion WebUI Forge, TextGen (text-generation-webui), Stability Matrix
Why is this happening?
Windows limits paths to 260 characters by default. AI programs have deeply nested folders (venv, custom nodes, model folders); if the program is also installed in a long path like Desktop or a OneDrive folder, the limit is quickly exceeded. Git for Windows refuses such files by default, and pip stops with an OSError.
How to fix it
- Install the program in a short path, for example
C:\KI\ComfyUI, not on the Desktop, in Downloads, or in OneDrive. - Enable long path support: Open PowerShell as administrator and run:
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force. Then restart the PC. - For Git as well:
git config --global core.longpaths true. Then repeat the clone or update command. - In Stability Matrix, there are separate switches for this in the settings: "Enable Long Paths" for Git and under System Settings for Windows.
- If pip reports that a single file or folder name is longer than 255 characters, this setting won't help; then the only option is a shorter installation path.
Set up from scratch again
If it still doesn’t work after that, a fresh setup step by step often helps:
- Set up and maintain ComfyUI on Windows
Desktop or Portable, where the models belong, sharing models with other programs, safely installing custom nodes, updates, startup options … - Your First Image with ComfyUI
Install Comfy Desktop, learn the interface, and create your first AI image with FLUX.2 [small] 4B or Z-Image Turbo. - Your First AI Video with LTX in ComfyUI
Use LTX-2.3 in ComfyUI to create short videos with sound from text or an image. Template, files, settings, and license.
Terms for this
Similar errors
- 'python' is not recognized or opens the Microsoft Store
- ERROR: Could not install packages due to an OSError: [WinError 5] Access is denied – pip cannot modify a file
- ImportError: DLL load failed while importing …: The specified module could not be found – a Python package is missing a Windows DLL
- No matching distribution found for torch (wrong Python version)
- pip: Microsoft Visual C++ 14.0 or greater is required
Sources
- https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation
- https://github.com/python/cpython/blob/main/Doc/using/windows.rst
- https://github.com/pypa/pip/blob/main/src/pip/_internal/commands/install.py
- https://github.com/git-for-windows/build-extra/blob/main/ReleaseNotes.md
- https://gitforwindows.org/git-cannot-create-a-file-or-directory-with-a-long-path.html
- https://raw.githubusercontent.com/LykosAI/StabilityMatrix/main/CHANGELOG.md
Checked on Oct 21, 2026. Didn't help? Ask in the forum and name the graphics card, program, and the full message.