0

I try to add big directory with long paths to CMake CPack NSIS win installer and have error related with long paths

CMake part:

install(
    DIRECTORY src/dir_with_long_file_paths
    DESTINATION dest
    )

cmd line cpack message:

cpack -C Release
CPack: Create package using NSIS
CPack: Install projects
CPack: - Install project: Project
CPack: Create package
CPack Error: Problem running NSIS command: "C:/Program Files (x86)/NSIS/makensis.exe" "C:/GitLabRunner/builds/fe33718a/0/Company/Project/build/_CPack_Packages/win64/NSIS/project.nsi"
Please check C:/GitLabRunner/builds/fe33718a/0/Company/Project/build/_CPack_Packages/win64/NSIS/NSISOutput.log for errors
CPack Error: Problem compressing the directory
CPack Error: Error when generating package: 

NSIS error message:

File: failed opening file "C:/Repo/NameOfInstallProgram/build/_CPack_Packages/win64/NSIS/Project\dest\dir1\dir2\dir3\dir4\dir5\dir6\dir7\dir8\dir9\dir10\file_with_very_long_name_bla_bla_bla.bla"
Andrii Rallo
  • 87
  • 1
  • 12
  • NSIS does not support long paths. Maybe try a relative path? – Anders Jul 06 '22 at 14:29
  • This is saving you from a crashing installer down the line. Not every Windows user will have long paths enabled (unfortunately). When that is the case, the installer will fail. – Alex Reinking Jul 06 '22 at 14:31

2 Answers2

0

This is probably not an issue with NSIS itself, but a Windows limitation. Have you tried enabling long paths in Powershell?

New-ItemProperty `
    -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" `
    -Name "LongPathsEnabled" `
    -Value 1 `
    -PropertyType DWORD `
    -Force

Further reading: Maximum Path Length Limitation

idleberg
  • 12,634
  • 7
  • 43
  • 70
-1

I fixed my issue to add 7z archive to installer and unpack it after installation . For unpack it I used Nsis7z plugin (when use plugins don`t forget about versions (ansi or unicode)).

Andrii Rallo
  • 87
  • 1
  • 12