Electron packager doesn't accept my icon file even though it is in the right dimensions and format.
Icon.zip
PS C:\Users\abornst\Documents\ovt> electron-packager . CNTKVideoTagger --platform=win32 --icon=Icon.ico --arch=x64
Packaging app for platform win32 x64 using electron v1.6.2
rcedit.exe failed with exit code 1. Fatal error: Unable to set icon
PS C:\Users\abornst\Documents\ovt> electron-packager . CNTKVideoTagger --platform=win32 --icon=.Icon.ico --arch=x64
Packaging app for platform win32 x64 using electron v1.6.2
Wrote new app to C:\Users\user\Documents\ovt\CNTKVideoTagger-win32-x64
Thanks for filing an issue! In order to help you with your problem, we're going to need more information about it. In particular:
Console output when you run electron-packager with the environment variable DEBUG=electron-packager.
Please provide either a failing minimal testcase (with code) or detailed steps to reproduce your
problem. Using electron-quick-start is a good starting point.
Since the original issue reporter has not responded to the request for additional information in over two weeks, I'm going to assume that they either found the answer in another manner or decided not to pursue this issue. If I'm incorrect, they can respond with answers to the questions posed, and I'll reopen.
Windows 10 64bit
"asar": "^0.13.0",
"electron": "^1.7.5",
"electron-packager": "^8.7.2"
Same problem here. I cant understand what do you mean by
Console output when you run electron-packager with the environment variable DEBUG=electron-packager.
Anyway, here are all the logs.
running npm run build when "build": "electron-packager . --out=dist/win --platform=win32 --arch=x64 --icon=favicon.ico --asar=true --overwrite"
gives
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'build' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle [email protected]~prebuild: [email protected]
6 silly lifecycle [email protected]~prebuild: no script for prebuild, continuing
7 info lifecycle [email protected]~build: [email protected]
8 verbose lifecycle [email protected]~build: unsafe-perm in lifecycle true
9 verbose lifecycle [email protected]~build: PATH: C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;E:\ElectronTutorial\node_modules\.bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\libnvvp;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Users\windows\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Git\cmd;C:\Program Files\dotnet\;C:\Program Files (x86)\GtkSharp\2.12\bin;C:\Program Files\nodejs\;C:\Program Files\MiKTeX 2.9\miktex\bin\x64\;C:\Program Files\Java\jdk1.8.0_73\bin;C:\OpenCV-3.3.0-vc14\opencv\build\x64\vc14\bin;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin;C:\Program Files\CMake\bin;C:\Ruby24-x64\bin;C:\Users\windows\AppData\Local\Programs\Python\Python35\Scripts\;C:\Users\windows\AppData\Local\Programs\Python\Python35\;C:\Program Files (x86)\Microsoft VS Code\bin;C:\cuDNN;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\extras\CUPTI\libx64;C:\Program Files\Docker Toolbox;C:\Users\windows\AppData\Roaming\npm;C:\Program Files\MongoDB\Server\3.2\bin
10 verbose lifecycle [email protected]~build: CWD: E:\ElectronTutorial
11 silly lifecycle [email protected]~build: Args: [ '/d /s /c',
11 silly lifecycle 'electron-packager . --out=dist/win --platform=win32 --arch=x64 --icon=favicon.ico --asar=true --overwrite' ]
12 silly lifecycle [email protected]~build: Returned: code: 1 signal: null
13 info lifecycle [email protected]~build: Failed to exec build script
14 verbose stack Error: [email protected] build: `electron-packager . --out=dist/win --platform=win32 --arch=x64 --icon=favicon.ico --asar=true --overwrite`
14 verbose stack Exit status 1
14 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:255:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:191:7)
14 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:191:7)
14 verbose stack at maybeClose (internal/child_process.js:877:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid [email protected]
16 verbose cwd E:\ElectronTutorial
17 error Windows_NT 10.0.10240
18 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
19 error node v6.9.4
20 error npm v3.10.10
21 error code ELIFECYCLE
22 error [email protected] build: `electron-packager . --out=dist/win --platform=win32 --arch=x64 --icon=favicon.ico --asar=true --overwrite`
22 error Exit status 1
23 error Failed at the [email protected] build script 'electron-packager . --out=dist/win --platform=win32 --arch=x64 --icon=favicon.ico --asar=true --overwrite'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the electron-tutorial package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error electron-packager . --out=dist/win --platform=win32 --arch=x64 --icon=favicon.ico --asar=true --overwrite
23 error You can get information on how to open an issue for this project with:
23 error npm bugs electron-tutorial
23 error Or if that isn't available, you can get their info via:
23 error npm owner ls electron-tutorial
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]
However running electron-packager . --out=dist/win --platform=win32 --arch=x64 --asar=true --overwrite works absolutely fine.
E:\ElectronTutorial>electron-packager . --out=dist/win --platform=win32 --arch=x64 --icon=favicon.ico --asar=true --overwrite
Packaging app for platform win32 x64 using electron v1.7.5
rcedit.exe failed with exit code 1. Fatal error: Unable to set icon
I cant understand what do you mean by [debug instructions]
Run SET DEBUG=electron-packager before running the command on Windows.
Please don't paste output of npm run commands, they do not capture the command's stderr/stdout. (This is a long-standing NPM bug.)
Fatal error: Unable to set icon
If it's unable to set the icon, then one of the following is true:
I dont think this would be helpful but here you go.
favicon.ico is 256x256, it opens fine with MS paint, same folder as package.json
E:\ElectronTutorial>SET DEBUG=electron-packager
E:\ElectronTutorial>electron-packager . --out=dist/win --platform=win32 --arch=x64 --icon=favicon.ico --asar=true --overwrite
electron-packager Electron Packager 8.7.2 +0ms
electron-packager Node v6.9.4 +4ms
electron-packager Host Operating system: win32 (x64) +3ms
electron-packager Packager Options: {"_":["."],"all":false,"deref-symlinks":true,"download":{"strictSSL":true},"overwrite":true,"prune":true,"quiet":false,"out":"dist/win","platform":"win32","arch":"x64","icon":"favicon.ico","asar":true,"dir":".","protocols":[]} +1ms
electron-packager Target Platforms: win32 +4ms
electron-packager Target Architectures: x64 +1ms
electron-packager Inferring application name from name in E:\ElectronTutorial\package.json +14ms
electron-packager Inferring appVersion from version in E:\ElectronTutorial\package.json +3ms
electron-packager Inferring target Electron version from electron in E:\ElectronTutorial\package.json +5ms
electron-packager Application name: electron-tutorial +1ms
electron-packager Target Electron version: 1.7.5 +2ms
electron-packager Ignored path regular expressions: [ '/node_modules/electron($|/)',
'/node_modules/electron-prebuilt(-compile)?($|/)',
'/node_modules/electron-packager($|/)',
'/\\.git($|/)',
'/node_modules/\\.bin($|/)',
'\\.o(bj)?$' ] +3ms
electron-packager Downloading Electron with options {"strictSSL":true,"platform":"win32","arch":"x64","version":"1.7.5"} +62ms
Packaging app for platform win32 x64 using electron v1.7.5
electron-packager Creating C:\Users\windows\AppData\Local\Temp\electron-packager\win32-x64-template +299ms
electron-packager Extracting C:\Users\windows\.electron\electron-v1.7.5-win32-x64.zip to C:\Users\windows\AppData\Local\Temp\electron-packager\win32-x64-template +18ms
electron-packager Initializing app in C:\Users\windows\AppData\Local\Temp\electron-packager\win32-x64\electron-tutorial-win32-x64 from C:\Users\windows\AppData\Local\Temp\electron-packager\win32-x64-template template +2s
electron-packager Ignored paths based on the out param: [ 'E:\\ElectronTutorial\\dist\\win' ] +4ms
electron-packager Pruning modules via: npm prune --production +2s
electron-packager Running asar with the options {} +5s
electron-packager Renaming electron.exe to electron-tutorial.exe in C:\Users\windows\AppData\Local\Temp\electron-packager\win32-x64\electron-tutorial-win32-x64 +16ms
electron-packager Running rcedit with the options {"version-string":{},"file-version":"1.0.0","product-version":"1.0.0","icon":"favicon.ico"} +15ms
rcedit.exe failed with exit code 1. Fatal error: Unable to set icon
If everything you say is accurate, then I'm inclined to believe that it's a bug in rcedit. Packager doesn't do anything except pass the icon path to rcedit, and it modifies the executable accordingly.
FWIW, I was seeing this same error when I tried building without an .ico file in the same directory as the .png specified in the config.
"electronPackagerConfig": {
"packageManager": "npm",
"icon": "./src/assets/imgs/icon-1024.png"
},

Reopen the thread maybe?
I'm not inclined to reopen this issue. This should not be a catch-all for a generic error message by rcedit (which needs to be more specific when possible). For the issue described by @positlabs, it would help to see what the electron-packager debug says is being passed to the rcedit module.
See also: https://github.com/electron/rcedit/pull/74, which is now in 1.1.0 of the rcedit module.
I confirm @positlabs's solution works.
I'm not seeing a solution there.
it's more of a workaround, sorry.
I'm not getting the exact same problem, but it seems pretty close. It's reported from electron forge:
An unhandled rejection has occurred inside Forge:
rcedit.exe failed with exit code 1. Cannot open icon file 's'
Not sure why the file is called 's'. When I try @positlabs' workaround (with an ico file that opens fine in paint at least, I get rcedit.exe failed with exit code 1. Reserved header is not 0 or image type is not icon for 's'.
We can build for windows on a mac, just not on windows due to the above. Does this seem like the same error? Or is it something else?
s is probably because I'm not good at C++ :disappointed:
Regarding the actual error, it appears to be a file that rcedit doesn't consider to be an ICO file that it can use.
This is how I resolved the issue.
I had an macOS icon file named icons.icns and a Windows icon file named icon.ico. This was my packagerConfig:
"electronPackagerConfig": {
"packageManager": "npm",
"icon": "./src/assets/images/icons.icns",
"asar": true
},
No matter what I specified in my electronWinstallerConfig I was still getting this error, even if I removed the icon key from it. I finally tracked down the issue by finding my globally installed electron-forge and adding a console.log to the rcedit.js file. It turns out that rcedit was taking the the path from electronPackagerConfig and ignoring the electronWinstallerConfig, then just renaming the extension to .ico. So rcedit couldn't find ./src/assets/images/icons.ico because it didn't exist.
Long story short: rename your icon files to have the same base name and in the same folder. In my case I now have these:
src/assets/images/icons.icns
src/assets/images/icons.ico
And everything works.
Following what @jaaromy did. I fixed mine with a config that looks like this:
electronPackagerConfig: {
icon: "src/assets/images/logo-icon.icns"
},
electronWinstallerConfig: {
iconUrl: "src/assets/images/logo-icon.ico"
},
Honest question: Are the docs for the icon option incomplete? https://github.com/electron-userland/electron-packager/blob/v12.1.0/docs/api.md#icon
If so, do people have suggestions for improving it?
@malept I know I got here from working with electron-forge. It's difficult to find the documentation that you need when working with things like electron-forge. Now, from your link, I see this which I would've loved to know many, many hours ago.
If the file extension is omitted, it is auto-completed to the correct extension based on the platform
However, an example showing how a Windows and MacOS icon would be set up would be helpful IMO.
It's difficult to find the documentation that you need when working with things like electron-forge.
Hmmm. It's linked in the README... Which Forge docs were you using?
I ended up here: https://github.com/electron/windows-installer#usage from the link in the Make section of the README. My electron-forge package was working but electron-forge make was failing at the time. It didn't help that I could do everything successfully on MacOS but things were failing on Windows. A more explicit error when using a platform specific icon extension might be helpful.
The electronWinstallerConfig section wasn't what I was talking about. Additionally, the rcedit errors were updated recently. Were you getting errors like this? https://github.com/electron-userland/electron-packager/issues/621#issuecomment-389590753
Yeah, I understood what you were speaking of. I was trying to give insight into how I ended up where I was to hopefully help prevent others from ending up there the same way. I think while we hope all documentation is read thoroughly it almost never is. So I got that error you linked #621 and searched for it. Which led me here. Which led me to Jaaromy who spoke of electronWinstallerConfig which took me to those docs, which led to my comment. Hope this helps.
Most helpful comment
This is how I resolved the issue.
I had an macOS icon file named
icons.icnsand a Windows icon file namedicon.ico. This was my packagerConfig:No matter what I specified in my
electronWinstallerConfigI was still getting this error, even if I removed theiconkey from it. I finally tracked down the issue by finding my globally installedelectron-forgeand adding aconsole.logto thercedit.jsfile. It turns out thatrceditwas taking the the path fromelectronPackagerConfigand ignoring theelectronWinstallerConfig, then just renaming the extension to.ico. Sorceditcouldn't find./src/assets/images/icons.icobecause it didn't exist.Long story short: rename your icon files to have the same base name and in the same folder. In my case I now have these:
src/assets/images/icons.icnssrc/assets/images/icons.icoAnd everything works.