electron-builder icon indicating copy to clipboard operation
electron-builder copied to clipboard

/D NSIS Flag does not support paths containing white spaces (e.g. C:/Program Files/)

Open gdotv opened this issue 6 months ago • 2 comments

  • Electron-Builder Version: 24.9.1
  • Node Version: 18 (LTS)
  • Electron Version: 25.6.0
  • Electron Type (current, beta, nightly): current

N/A

  • Target: Windows (NSIS)

The /D flag for the NSIS installer in command line mode is not properly parsing/handling file paths containing spaces. The issue appears to be occurring in the parsing stage of the /D flag in multiUser.nsh (https://github.com/electron-userland/electron-builder/blob/master/packages/app-builder-lib/templates/nsis/multiUser.nsh#L45). A very simple test to reproduce the issue (on a Windows device) is to attempt running the NSIS installer in "quiet" mode with an override path containing a white space, for instance in my case: ./gdotv.exe /S /D=C:\Program Files\gdotv

The expected output of this command is for gdotv.exe to be installed under C:\Program Files\gdotv, however it ends up being installed under C:\Program I've also tried different permutations with and without quotes but to no avail, e.g.: ./gdotv.exe /S /D="C:\Program Files\gdotv" fails the installation altogether ./gdotv.exe /S /D='C:\Program Files\gdotv' also fails the installation altogether

For reference, https://nsis.sourceforge.io/Docs/Chapter3.html, section 3.2 suggests the /D flag should allow for white spaces (and therefore be the last flag in the command). I'm unfortunately not familiar with nsh scripts but I expect the solution here would be to modify the parsing of the /D flag such that it either supports quotes or sticking to NSIS standard just captures the rest of the command (everything after /D=, effectively) as the value of the parameter.

This can be reproduced with a minimal, default NSIS build via electron-builder, no extra configuration required.

gdotv avatar Dec 13 '23 14:12 gdotv

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Feb 12 '24 00:02 github-actions[bot]

It'd be really nice if /D worked with paths with spaces, given that the common use case one might want to use /D for is to change the install directory for the one-click installer to C:\Program Files\foo.

ravicious avatar Feb 12 '24 09:02 ravicious