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.

  1. 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.
  2. 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.
  3. To make a link in dirB to point to dirA:
    1. Open a command (cmd.exe) or PowerShell® interface.
    2. Use the cd command to navigate to dirB.
    3. Make a link that points from dirB to dirA: mklink /D s1 C:\Users\XXXXX\work\files\looooooooongDirectoryNamesHere.
    4. 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.
    5. 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.

  1. Select a drive letter not in use. For this example X:.
  2. Open a command (cmd.exe) or PowerShell® interface.
  3. Use the cd command to navigate to dirA.
  4. Create a drive that starts in dirB. Run subst x: .
  5. Open the project in the IDE using X:.
  6. In this case the project would be shortened to X:src\firmware\Mplab.X.
  7. Alternately in X:, cd src\firmware\Mplab.X and run make.