How to debug nsis script?
I have upgraded from Ubuntu 19.10 to 20.04 which seems to update nsis from v3.04-1 to v3.05-2. Now I get an error with my script:
# makensis installer.nsi
Processing config: /etc/nsisconf.nsh
Processing script file: "installer.nsi" (UTF8)
Error: unterminated string parsing line at macro:_IncludeStrFunction:7
Error in macro _IncludeStrFunction on macroline 7
!include: error in script: "../src/other/EnvVarUpdate.nsh" on line 49
Error in script "installer.nsi" on line 2 -- aborting creation process
My script is this:
OutFile speedata-publisher-windows-386-3.9.14-installer.exe
!include "../src/other/EnvVarUpdate.nsh"
InstallDir $PROGRAMFILES\speedata-publisher
DirText "This will install speedata Publisher on your computer. Choose a directory"
Section
SetOutPath $INSTDIR
RMDir /r /REBOOTOK $INSTDIR
File /r /tmp/publisher-git/build/speedata-publisher\*.*
${EnvVarUpdate} $0 "PATH" "A" "HKCU" "$INSTDIR\bin"
WriteUninstaller $INSTDIR\Uninstall.exe
MessageBox MB_OK "Run speedata Publisher with 'sp' on the command.com prompt"
SectionEnd
Section "Uninstall"
${un.EnvVarUpdate} $0 "PATH" "R" "HKCU" "$INSTDIR\bin"
RMDir /r /REBOOTOK $INSTDIR
SectionEnd
and the EnvVarUpdate.nsh
is from https://nsis.sourceforge.io/Environmental_Variables:_append,_prepend,_and_remove_entries
The line 49 in this script is !insertmacro _IncludeStrFunction StrTok
The output of my command with the previous version 3.04-1 is:
Processing config: /etc/nsisconf.nsh
Processing script file: "build/installer.nsi" (UTF8)
Processed 1 file, writing output (x86-ansi):
Output: "/tmp/publisher-git/build/speedata-publisher-windows-386-3.9.14-installer.exe"
Install: 2 pages (128 bytes), 1 section (4120 bytes), 1139 instructions (31892 bytes), 647 strings (11565 bytes), 1 language table (230 bytes).
Uninstall: 1 page (128 bytes), 1 section (4120 bytes), 385 instructions (10780 bytes), 100 strings (1387 bytes), 1 language table (194 bytes).
Datablock optimizer saved 650630 bytes (~1.8%).
Using zlib compression.
EXE header size: 75264 / 76288 bytes
Install code: 10537 / 45255 bytes
Install data: 34526923 / 62531730 bytes
Uninstall code+data: 2665 / 3163 bytes
CRC (0xFE2E922E): 4 / 4 bytes
Total size: 34615393 / 62656440 bytes (55.2%)
I am not really into nsis scripts, so I would like to know how to find where the problem could be.
There was a change to how StrFunc works internally and the 3rd-party EnvVarUpdate.nsh file from the Wiki is incompatible with it.
As discussed here, you could try fixing EnvVarUpdate.nsh by changing !define un.${StrFuncName} "${Un${StrFuncName}}"
to
!define un.${StrFuncName} '${Un${StrFuncName}}'
.
Instead of manually patching that file, I would recommend that you use the EnVar plug-in as a replacement.