electron-userland / electron-builder

A complete solution to package and build a ready for distribution Electron app with “auto update” support out of the box
https://www.electron.build
MIT License
13.61k stars 1.74k forks source link

Large Apps Result in Malformed NSIS Installer After Build - No Error(s) #8399

Open Bug-Reaper opened 1 month ago

Bug-Reaper commented 1 month ago

I'm building an NSIS installer for a large electron app on an M1 MacPro. Not getting any errors or anything via command DEBUG=electron-builder:* electron-builder --windows --x64....

However the result AppName Setup 0.0.0.exe file does not work when put on a windows machine. When attempting to launch the installer it cannot find the binary to run see screenshot:

Screenshot 2024-08-05 at 2 45 26 AM

Seems like the only thing packaged in the exe is the uninstaller, at least when you browse that's the only thing present. Can also pretty clearly see something has gone awry as win-unpacked is ~4Gib and the installer exe is a mere 300mb.

My NSIS config is as follows:

win:{
      target:"nsis",
      icon:"build/SoundSafari.ico",
    },
    nsis:{
      oneClick:true,
      installerIcon:"build/SoundSafari.ico",
      installerHeaderIcon:"build/SoundSafari.ico",
      uninstallDisplayName:`SoundSafari-ver(${VERSION})`,
      deleteAppDataOnUninstall:true,
      runAfterFinish:true,
      createDesktopShortcut:true,
      createStartMenuShortcut:true
    }
Bug-Reaper commented 1 month ago

I may try and build on my x64 Win11 VM to see if error is specific to my M1 mac. Also want to try customNsisBinary but the correct usage is not clear.

Bug-Reaper commented 1 month ago

Essentially this is the same problem as https://github.com/electron-userland/electron-builder/issues/6738 .

However the fix used there does not fix for me :'(

Bug-Reaper commented 1 month ago

Build completes with no errors but I end up with an installer.exe that is empty except for the uninstaller.


Continued debug attempts:

  1. Tried $env /usr/bin/arch -x86_64 /bin/zsh --login before build to see if it did any magic.
  2. Tried the XL Nsis binary drop-in work-around (in case max nsis size was messing me up) https://github.com/electron-userland/electron-builder-binaries/issues/44
  3. Used system wine (got rid of some wine warnings but otherwise no change)

EDIT: have now also tried:

  1. Went through the pain of building directly on Windows 11 x64 and got rekt by the same issue.
  2. Removed all config options and went with defaults.
  3. Tried bumping electron version to @latest ^31.3.1
Bug-Reaper commented 1 month ago

After days of all-in debugging for days 10+ hrs I'm happy to report I have some progress.

Was able to get a windows-installer that is functional via the nsis-installer-large-files workaround but only when building on windows x64. The exact instructions were as follows:

  1. Download special NSISBI from https://sourceforge.net/projects/nsisbi/
  2. Extract and copy all contained filed into C:\Users\user\AppData\Local\electron-builder\Cache\electron-builder\nsis\nsis-3.0.4.1 and "replace all" when prompted.
  3. Delete NSIS.exe from above cache folder and rename newly copied makensisw.exe => NSIS.exe.
  4. re-run build

This type of NSIS build changes the output as a side-effect, you'll see two files now comprise the installer:

.exe (~100kb). .nsisbin (Your actual app-size (~4Gib for me)). ---- # What's next for this issue First I'd like to test if the two-file installer setup (.exe && .nsbin) files breaks my ability to auto-update. Looking at the generated `latest.yml` that only mentions the exe file I'd wager it does brick auto-updates. If someone more intimate with the auto-updater wants to weigh in though that'd be appreciated. Here's a bunch of other stuff I hope to PR in fixes for (any help appreciated) : 1. Builder should throw an error for large-apps instead of building an unusable nsis installer with no warnings/errors. 2. Document proper build instructions for NSIS builds of large-apps. Add a config option for it if possible. 3. Figure out how to build large NSIS installers on non-windows devices. Following the above workaround on macOS for example results in an error from nsis-3.0.4.1/mac/makensis.sh `Invalid command: "GetWinVer"`. ---- TLDR: Most egregious thing is: > Builder should throw an error for large-apps instead of building an unusable nsis installer with no warnings/errors." Other build types work fine so the error should happen specifically during NSIS flavored builds. We're hitting some ancient window98 restriction on max NSIS file size either 2 or 4Gib I think. If you read through the whole post and want to leave a comment/emoji for moral support that'd be appreciated.
Bug-Reaper commented 1 month ago

Builder should throw an error for large-apps instead of building an unusable nsis installer with no warnings/errors.

I want to check the <installerName>.nsis.7z file size prior to it making the final exe. Maybe need to PR this upstream @electron-forge-nsis-maker? Does electron-builder use forge for all NSIS builds?

https://github.com/electron-userland/electron-builder/blob/12c52a81420f04ec0e205dd83798c2b0b773011d/packages/electron-forge-maker-nsis/main.js