Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot create an installer with electron-winstaller: “Stream was too long” #308

Open
tg-programmer opened this issue Jul 5, 2019 · 4 comments

Comments

@tg-programmer
Copy link

I've been trying to create a Windows installer for my Electron application with the electron-winstaller module by running the following code:

const createWindowsInstaller = require('electron-winstaller').createWindowsInstaller
const path = require('path')

getInstallerConfig()
  .then(createWindowsInstaller)
  .catch((error) => {
    console.error(error.message || error)
    process.exit(1)
  })

function getInstallerConfig () {
  const installerPath = path.join('.');
  const releaseBuildsPath = path.join('..', '..', 'release-builds');
  const assetsPath = path.join('..', '..', 'assets');

  return Promise.resolve({
    appDirectory: path.join(releaseBuildsPath, '[application name]-win32-x64'),
    authors: '[my name]',
    noMsi: true,
    outputDirectory: installerPath,
    exe: '[application name].exe',
    setupExe: '[application name].exe',
    setupIcon: path.join(assetsPath, 'demo.ico'),
  })
}

However, I keep getting the following error:

Failed with exit code: 1
Output:
Attempting to build package from '[application name].nuspec'.
lib/net45/resources/app.asar
Stream was too long.

The script I ran to create the windows package is this:

electron-packager . [application name] --overwrite --asar --platform=win32 --arch=x64 --icon=assets/demo.ico --prune=true --out=release-builds

With the asar option enabled and the prune flag set to true, I don't see any other options for reducing the size of the app.asar file, which supposedly is too large and causing this issue.

I also don't quite understand where the lib/net45/resources/app.asar file shown in the above error message is located; there is no directory named "lib" or "net45" on my system (macOS Mojave).

Here is the detailed result of running the script with the debugging output enabled:

  electron-windows-installer:main Using Mono: 'mono' +0ms
  electron-windows-installer:main Using Wine: 'wine' +2ms
  electron-windows-installer:main Created NuSpec file:
  electron-windows-installer:main <?xml version="1.0" encoding="utf-8"?>
  electron-windows-installer:main <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
  electron-windows-installer:main   <metadata>
  electron-windows-installer:main     <id>[application name]</id>
  electron-windows-installer:main     <title>[application name]</title>
  electron-windows-installer:main     <version>1.0.0</version>
  electron-windows-installer:main     <authors>tg</authors>
  electron-windows-installer:main     <owners>tg</owners>
  electron-windows-installer:main     <iconUrl>https://raw.githubusercontent.com/atom/electron/master/atom/browser/resources/win/atom.ico</iconUrl>
  electron-windows-installer:main     <requireLicenseAcceptance>false</requireLicenseAcceptance>
  electron-windows-installer:main     <description>A desktop vocabulary builder app</description>
  electron-windows-installer:main     <copyright>Copyright © 2019 tg</copyright>
  electron-windows-installer:main   </metadata>
  electron-windows-installer:main   <files>
  electron-windows-installer:main     <file src="locales/**" target="lib/net45/locales" />
  electron-windows-installer:main     <file src="resources/**" target="lib/net45/resources" />
  electron-windows-installer:main     <file src="*.bin" target="lib/net45" />
  electron-windows-installer:main     <file src="*.dll" target="lib/net45" />
  electron-windows-installer:main     <file src="*.pak" target="lib/net45" />
  electron-windows-installer:main     <file src="*.exe.config" target="lib/net45" />
  electron-windows-installer:main     <file src="*.exe.sig" target="lib/net45" />
  electron-windows-installer:main     <file src="icudtl.dat" target="lib/net45/icudtl.dat" />
  electron-windows-installer:main     <file src="Squirrel.exe" target="lib/net45/squirrel.exe" />
  electron-windows-installer:main     <file src="LICENSE" target="lib/net45/LICENSE" />
  electron-windows-installer:main     <file src="[application name].exe" target="lib/net45/[application name].exe" />
  electron-windows-installer:main   </files>
  electron-windows-installer:main </package>
  electron-windows-installer:main  +7s
Failed with exit code: 1
Output:
Attempting to build package from '[application name].nuspec'.
lib/net45/resources/app.asar
Stream was too long.

Any suggestion will be greatly appreciated.

@Alexie81
Copy link

Alexie81 commented Aug 3, 2021

I've been trying to create a Windows installer for my Electron application with the electron-winstaller module by running the following code:

const createWindowsInstaller = require('electron-winstaller').createWindowsInstaller
const path = require('path')

getInstallerConfig()
  .then(createWindowsInstaller)
  .catch((error) => {
    console.error(error.message || error)
    process.exit(1)
  })

function getInstallerConfig () {
  const installerPath = path.join('.');
  const releaseBuildsPath = path.join('..', '..', 'release-builds');
  const assetsPath = path.join('..', '..', 'assets');

  return Promise.resolve({
    appDirectory: path.join(releaseBuildsPath, '[application name]-win32-x64'),
    authors: '[my name]',
    noMsi: true,
    outputDirectory: installerPath,
    exe: '[application name].exe',
    setupExe: '[application name].exe',
    setupIcon: path.join(assetsPath, 'demo.ico'),
  })
}

However, I keep getting the following error:

Failed with exit code: 1
Output:
Attempting to build package from '[application name].nuspec'.
lib/net45/resources/app.asar
Stream was too long.

The script I ran to create the windows package is this:

electron-packager . [application name] --overwrite --asar --platform=win32 --arch=x64 --icon=assets/demo.ico --prune=true --out=release-builds

With the asar option enabled and the prune flag set to true, I don't see any other options for reducing the size of the app.asar file, which supposedly is too large and causing this issue.

I also don't quite understand where the lib/net45/resources/app.asar file shown in the above error message is located; there is no directory named "lib" or "net45" on my system (macOS Mojave).

Here is the detailed result of running the script with the debugging output enabled:

  electron-windows-installer:main Using Mono: 'mono' +0ms
  electron-windows-installer:main Using Wine: 'wine' +2ms
  electron-windows-installer:main Created NuSpec file:
  electron-windows-installer:main <?xml version="1.0" encoding="utf-8"?>
  electron-windows-installer:main <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
  electron-windows-installer:main   <metadata>
  electron-windows-installer:main     <id>[application name]</id>
  electron-windows-installer:main     <title>[application name]</title>
  electron-windows-installer:main     <version>1.0.0</version>
  electron-windows-installer:main     <authors>tg</authors>
  electron-windows-installer:main     <owners>tg</owners>
  electron-windows-installer:main     <iconUrl>https://raw.githubusercontent.com/atom/electron/master/atom/browser/resources/win/atom.ico</iconUrl>
  electron-windows-installer:main     <requireLicenseAcceptance>false</requireLicenseAcceptance>
  electron-windows-installer:main     <description>A desktop vocabulary builder app</description>
  electron-windows-installer:main     <copyright>Copyright © 2019 tg</copyright>
  electron-windows-installer:main   </metadata>
  electron-windows-installer:main   <files>
  electron-windows-installer:main     <file src="locales/**" target="lib/net45/locales" />
  electron-windows-installer:main     <file src="resources/**" target="lib/net45/resources" />
  electron-windows-installer:main     <file src="*.bin" target="lib/net45" />
  electron-windows-installer:main     <file src="*.dll" target="lib/net45" />
  electron-windows-installer:main     <file src="*.pak" target="lib/net45" />
  electron-windows-installer:main     <file src="*.exe.config" target="lib/net45" />
  electron-windows-installer:main     <file src="*.exe.sig" target="lib/net45" />
  electron-windows-installer:main     <file src="icudtl.dat" target="lib/net45/icudtl.dat" />
  electron-windows-installer:main     <file src="Squirrel.exe" target="lib/net45/squirrel.exe" />
  electron-windows-installer:main     <file src="LICENSE" target="lib/net45/LICENSE" />
  electron-windows-installer:main     <file src="[application name].exe" target="lib/net45/[application name].exe" />
  electron-windows-installer:main   </files>
  electron-windows-installer:main </package>
  electron-windows-installer:main  +7s
Failed with exit code: 1
Output:
Attempting to build package from '[application name].nuspec'.
lib/net45/resources/app.asar
Stream was too long.

Any suggestion will be greatly appreciated.

I think is just:

const electronInstaller = require('electron-winstaller');

@Bug-Reaper
Copy link

Building for windows x64 on M1 MacOS via electron forge:

An unhandled rejection has occurred inside Forge:
Error: Failed with exit code: 1
Output:
Attempting to build package from '[application name].nuspec'.
lib/net45/resources/app.asar
Stream was too long.
at ChildProcess.<anonymous> (/[project path]/node_modules/electron-winstaller/lib/spawn-promise.js:48:24)
    at ChildProcess.emit (node:events:513:28)
    at ChildProcess.emit (node:domain:489:12)
    at maybeClose (node:internal/child_process:1100:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)

My app is 4Gib -- I'm gonna take a look at spawn-promise.js:48:24. Perhaps also explore work-around with unpacking ASAR

@Bug-Reaper
Copy link

Bug-Reaper commented Aug 3, 2024

Examination of spawn-promise.js did not yield anything interesting at a glance. Though I added extra logging and it appears we're attempting to run:

nuget.exe pack [temp dir]/[app name].nuspec -BasePath [project path]/out/[app name]-win32-x64 -OutputDirectory [tmp path]/[tmp file].lgig -NoDefaultExcludes

The word on the street is that windows doesn't allow exe files over 4Gib though there are ways to tell Windows to load only a specific section of the exe file. Possibly related but I get the gist that's more of a runtime constraint and not a creation constraint.

EDIT : Also related the wonderful people at chocolatey apparently got around this via "different methods to create nupkgs". By far the most promising lead. chocolatey/choco#2278


No idea how to package my app for windows with auto-updates lol fantastic.

@Bug-Reaper
Copy link

Bug-Reaper commented Aug 3, 2024

Fixed it via using a newer version of NuGet.exe :

  1. Download https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
  2. In your project folder replace node_modules/electron-winstaller/vendor/nuget.exe with the exe you downloaded.
  3. Re-run your build.

You can also use --vendorOverride [path] to force winstaller to use your own custom vendor folder. but for an easy short-term fix dropping the exe into place is much easier

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants