12.5.2 Destination Path Too Long/The filename or extension is too long (Windows® OS)
Windows OS has a maximum path length of 260 characters and a command-line limitation for Windows OS of 8191 characters. For details, see 6.6.5 Path, File and Folder Name Restrictions.
Workarounds for long paths are discussed below.
mklink Workaround
Use mklink to create shortcuts in a directory with a short path to projects files in directory with a long path.
- Find the directory with the shortest path (from the root) that contains all the source files for a given project. For example, if the project is in C:\Users\XXXXX\work\files\looooooooongDirectoryNamesHere\src\firmware\Mplab.X but all project files, referenced via relative paths, are in C:\Users\XXXXX\work\files\looooooooongDirectoryNamesHere, then the later directory is the one with the shortest path. Call this dirA.
- Create a new directory with a shorter path that will contain shortcuts to the actual files. How to link this directory with dirA will be explained in the next step. But to continue the example, consider the new directory is C:\Users\XXXXX\shortcuts. Call this dirB.
- To make a link in dirB to
point to dirA:
- Open a command (cmd.exe) or PowerShell® interface.
- Use the
cd
command to navigate to dirB. - Make a link that points
from dirB to dirA:
mklink /D s1 C:\Users\XXXXX\work\files\looooooooongDirectoryNamesHere
. - Open the project in the
IDE using dirB and
s1
. In this case the project directory would be shortened to: C:\Users\XXXXX\shortcuts\s1\src\firmware\Mplab.X. - Alternately in
dirB,
cd s1\src\firmware\Mplab.X
and then run make.
Virtual Drive Workaround
Use the same technique as in the previous section, but instead of a symbolic link, use a drive letter.
- Select a drive letter not in use. For this example X:.
- Open a command
(
cmd.exe
) or PowerShell® interface. - Use the
cd
command to navigate to dirA. - Create a drive that starts in
dirB. Run
subst x:
. - Open the project in the IDE using X:.
- In this case the project would be shortened to X:src\firmware\Mplab.X.
- Alternately in
X:,
cd src\firmware\Mplab.X
and run make.