System.ComponentModel.Win32Exception: The system cannot find the file specified when running on azure agent
Pre-flight checklist
- [x] I have read the contribution documentation for this project.
- [x] I agree to follow the code of conduct that this project uses.
- [x] I have searched the issue tracker for a bug that matches the one I want to file, without success.
Forge version
7.6.1
Electron version
35.0.2
Operating system
Windows server 2019, Windows server 2022, Windows server 2025
Last known working Forge version
7.6.1
Expected behavior
When running electron forge make script on azure pipeline agent, forge should create the distributable files for the application
Actual behavior
When I run 'make' script on azure pipeline agent, it fails on step 'Making a squirrel distributable for win32/x64'. The exception trace is:
× Making a squirrel distributable for win32/x64 [FAILED: Failed with exit code: 4294967295 Output: System.AggregateException: One or more errors occurred. ---> System.ComponentModel.Win32Exception: The system cannot find the file specified at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start(ProcessStartInfo startInfo) at Squirrel.Utility.<InvokeProcessAsync>d__11.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Squirrel.Utility.<CreateZipFromDirectory>d__23.MoveNext() --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at Squirrel.ReleasePackage.CreateReleasePackage(String outputFile, String packagesRootDir, Func2 releaseNotesProcessor, Action1 contentsPostProcessHook) at Squirrel.Update.Program.Releasify(String package, String targetDir, String packagesDir, String bootstrapperExe, String backgroundGif, String signingOpts, String baseUrl, String setupIcon, Boolean generateMsi, Boolean packageAs64Bit, String frameworkVersion, Boolean generateDeltas) at Squirrel.Update.Program.executeCommandLine(String[] args) at Squirrel.Update.Program.main(String[] args) at Squirrel.Update.Program.Main(String[] args) ---> (Inner Exception #0) System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start(ProcessStartInfo startInfo) at Squirrel.Utility.<InvokeProcessAsync>d__11.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Squirrel.Utility.<CreateZipFromDirectory>d__23.MoveNext()<---
Steps to reproduce
- Create an electron application and push it to a repo on azure devops
- Configure squirrel maker
- Run make script
Additional information
The process was working before, my last successful run was on October 18th, 2024. I searched for similar issues and I found that GitHub issue, and also that StackOverflow question, but none of the proposed fixes worked. It works fine on my machine, using Windows 11. I also tried to run that on an ubuntu agent, with mono and wine installed, and I got an error related to the graphics driver. I really don't know what's that related to, I tried running my previous commit, which triggered the last successful run and it also failed.
Related issue: https://github.com/electron/forge/issues/3900
@shirakaba I had a look at the issue you mentioned, I'm using pnpm and webpack (not vite). The script works on my local machine, but not in azure agents
I’m experiencing this when building locally on an ARM VM (possibly cross-compiling to x64 – need to check), building with Webpack in a pnpm monorepo. However, I’ve set node-linker=hoisted so it should look pretty similar to an npm monorepo.
I’m hoping to attach a debugger to it to figure out which path it’s failing on. Just haven’t had a moment to look deeply into it yet. Need to compare to my two x64 machines and CI, too. I actually don’t have any working configuration yet – just failed like this on the first one I tried.
Just checked. Happens locally on my x64 machine as well (same monorepo).
Here are the log files I got from node_modules/electron-winstaller/vendor/Squirrel-Releasify.log (copied via OCR, so may have some typos).
[04/04/25 08:48:38] info: Program: Starting Squirrel Updater: --releasify C:\Users\jamie\AppData\Local\Temp\si-202534-2164-x15jZ0.8151m\electron_app.1.0.0.nupkg --releaseDir C:\Users\jamie\git\banana_native\apps\electron-app\out\make\squirrel.windows\x64 --loadingGif C:\Users\jamie\git\banana_native\node[truncated]
[04/04/25 08:48:38] info: Program: Bootstrapper EXE found at:C:\Users\jamie\git\banana_native\node_modules\electron-winstaller\vendor\Setup.exe
[04/04/25 08:48:38] info: Program: Creating release package: C:\Users\jamie\git\banana_native\apps\electron-app\out\make\squirrel.Windows\x64\electron_app.1.0.0.nupkg
[04/04/25 08:48:38] info: ReleasePackage: Creating release package: C:\Users\jamie\git\banana_native\apps\electron-app\out\make\squirrel.windows\x64\electron_app.1.0.0.nupkg => C:\Users\jamie\git\banana_native\apps\electron-app\out\make\squirrel.windows\x64\electron_app-1.0.0-full.nupkg
[04/04/25 08:48:43] info: ReleasePackage: Extracting dependent packages: []
[04/04/25 08:48:43] info: ReleasePackage: Removing unnecessary data
[04/04/25 08:48:43] info: ReleasePackage: No release notes found in C:\Users\jamie\AppData\Local\SquirrelTemp\tempa\electron_app.nuspec
[04/04/25 08:48:43] error: Utility: Failed to extract file C:\Users\jamie\git\banana_native\apps\electron-app\out\make\squirrel.windows\x64\electron_app-1.0.0-full.nupkg to C:\Users\jamie\AppData\Local\SquirrelTemp\tempa
The system cannot find the file specified
[04/04/25 08:48:43] fatal: Finished with unhandled exception: System.AggregateException: One or more errors occurred. ---› System.ComponentModel.Win32Exception:
The logs indicate that the following file was missing:
C:\Users\jamie\git\banana_native\apps\electron-app\out\make\squirrel.windows\x64\electron_app-1.0.0-full.nupkg
While electron_app.1.0.0.nupkg was present alongside it, indeed electron_app-1.0.0-full.nupkg was missing. This indicates that this step must have either failed silently or not finished in time:
[04/04/25 08:48:38] info: ReleasePackage: Creating release package: C:\Users\jamie\git\banana_native\apps\electron-app\out\make\squirrel.windows\x64\electron_app.1.0.0.nupkg => C:\Users\jamie\git\banana_native\apps\electron-app\out \make\squirrel.windows\x64\electron_app-1.0.0-full.nupkg
It sounds similar to https://github.com/Squirrel/Squirrel.Windows/issues/539.
I inspected node_modules\electron-winstaller\lib\index.js, with a debug breakpoint on the block that adds the --setupIcon flag (lines 301-321 at the time of writing), to work out what the full command to generate that electron_app.1.0.0.nupkg might be. If I'm right, in my case, it's as follows:
"C:\Users\AdminUser\git\banana_native\node_modules\electron-winstaller\vendor\Squirrel.exe" --releasify "C:\Users\RootUser\AppData\Local\Temp\si-202535-21060-mina4t.5zwzm\electron_app.1.0.0.nupkg" --releaseDir "C:\Users\AdminUser\git\banana_native\apps\electron-app\out\make\squirrel.windows\x64" --loadingGif "C:\Users\AdminUser\git\banana_native\node_modules\electron-winstaller\resources\install-spinner.gif" --no-msi
I set a breakpoint in a Node.js debugging terminal so that I could run the command manually without the temporary directory getting cleared away. I confirmed in Powershell (the shell I was running pnpm make in) that all directories and files in that script existed.
So given the inputs are all present, I wonder what it's failing on. Maybe it's something the Squirrel logic is doing internally. Of note, later on in the logs, it says it's going to extract to: C:\Users\AdminUser\AppData\Local\SquirrelTemp\tempa. However, I don't have such a directory, whether under AdminUser or RootUser.
It seems a lot of users solve problems, particularly in CI, by explicitly specifying SQUIRREL_TEMP. A little bit of background on SQUIRREL_TEMP (and its technical challenges) here.
So I tried passing SQUIRREL_TEMP:
$env:SQUIRREL_TEMP='C:\Users\AdminUser\git\banana_native\apps\electron-app\squirrel-temp'; "C:\Users\AdminUser\git\banana_native\node_modules\electron-winstaller\vendor\Squirrel.exe" --releasify "C:\Users\RootUser\AppData\Local\Temp\si-202535-21060-mina4t.5zwzm\electron_app.1.0.0.nupkg" --releaseDir "C:\Users\AdminUser\git\banana_native\apps\electron-app\out\make\squirrel.windows\x64" --loadingGif "C:\Users\AdminUser\git\banana_native\node_modules\electron-winstaller\resources\install-spinner.gif" --no-msi
Unfortunately, although I can see it's honouring that environment variable (because it creates the squirrel-temp directory), I still get the same error of System.ComponentModel.Win32Exception: The system cannot find the file specified.
I think I figured it out! I ran this command again:
$env:SQUIRREL_TEMP='C:\Users\AdminUser\git\banana_native\apps\electron-app\squirrel-temp'; "C:\Users\AdminUser\git\banana_native\node_modules\electron-winstaller\vendor\Squirrel.exe" --releasify "C:\Users\RootUser\AppData\Local\Temp\si-202535-21060-mina4t.5zwzm\electron_app.1.0.0.nupkg" --releaseDir "C:\Users\AdminUser\git\banana_native\apps\electron-app\out\make\squirrel.windows\x64" --loadingGif "C:\Users\AdminUser\git\banana_native\node_modules\electron-winstaller\resources\install-spinner.gif" --no-msi
And I looked closer at this error stack:
C:\Users\AdminUser\git\banana_native\apps\electron-app> System.AggregateException: One or more errors occurred. ---> System.ComponentModel.Win32Exception: The system cannot find the file specified
at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at Squirrel.Utility.<InvokeProcessAsync>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Squirrel.Utility.<CreateZipFromDirectory>d__23.MoveNext()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at Squirrel.ReleasePackage.CreateReleasePackage(String outputFile, String packagesRootDir, Func`2 releaseNotesProcessor, Action`1 contentsPostProcessHook)
at Squirrel.Update.Program.Releasify(String package, String targetDir, String packagesDir, String bootstrapperExe, String backgroundGif, String signingOpts, String baseUrl, String setupIcon, Boolean generateMsi, Boolean packageAs64Bit, String frameworkVersion, Boolean generateDeltas)
at Squirrel.Update.Program.executeCommandLine(String[] args)
at Squirrel.Update.Program.main(String[] args)
at Squirrel.Update.Program.Main(String[] args)
---> (Inner Exception #0) System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified
at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at Squirrel.Utility.<InvokeProcessAsync>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Squirrel.Utility.<CreateZipFromDirectory>d__23.MoveNext()<---
I looked into the Squirrel.Utility.<CreateZipFromDirectory> method. I noticed that it searches for 7z.exe:
https://github.com/Squirrel/Squirrel.Windows/blob/51f5e2cb01add79280a53d51e8d0cfa20f8c9f9f/src/Squirrel/Utility.cs#L373
I recognised the "vendor" folder as belonging to the npm package named electron-winstaller (git repo at electron/windows-installer). I checked, and saw that it distributes the following files (amongst others):
vendor\7z-arm64.dll
vendor\7z-arm64.exe
vendor\7z-x64.dll
vendor\7z-x64.exe
Notice how there's no vendor\7z.exe! They're all namespaced by architecture.
I'm using an x64-based computer, so I took a copy of 7z-x64.exe and 7z-x64.dll and renamed it to remove the architecture suffix:
vendor\7z-arm64.dll
vendor\7z-arm64.exe
vendor\7z-x64.dll
vendor\7z-x64.exe
+ vendor\7z.dll
+ vendor\7z.exe
I re-ran the command and this time, there was no exception thrown!
Curiously, it seems there's a script for automating exactly this in electron-wininstaller:
https://github.com/electron/windows-installer/blob/1cbccc43f6a87f37e20f343172e33448d860e626/script/select-7z-arch.js#L14
It seems it's supposed to run on the npm install lifecycle:
https://github.com/electron/windows-installer/blob/1cbccc43f6a87f37e20f343172e33448d860e626/package.json#L22
I believe this problem affects pnpm because, by default, it blocks all preinstall, install, and postinstall scripts:
If
onlyBuiltDependenciesFileandneverBuiltDependenciesare not set, this configuration option will default to blocking all install scripts.
So I expect that the fix, if you've not configured onlyBuildDependenciesFile yet, is to add this key into your pnpm-workspace.yaml:
onlyBuiltDependencies:
- electron-winstaller
Then:
- if you've not installed the monorepo yet, run
pnpm install. - if you've already installed the monorepo, run
pnpm store prune; pnpm rebuild electron-winstallerto clear the side-effects cache and re-run the install script for that package.
I tried my suggested instructions. Still doesn't run the install script, at least on pnpm v9.15.9. No idea why. Feels like a bug in pnpm.
Instead, we can forcibly run the 'install' script via:
cd node_modules\electron-winstaller
pnpm run install
# or `npm run install` or `node --run install` - whichever you prefer.
I created a little Node.js script (sorry, need permission to opensource) that checks whether 7z.exe is present or not, and if not, runs those steps above to trigger it manually. I reference the script in package.json as a premake script so that it runs before the make script.
That change finally makes my release build succeed!
EDIT: I think this unexpected behaviour was happening to me simply because the onlyBuiltDependencies in package.json (which I hadn’t spotted) overrides any specified in pnpm-workspace.yaml. The solution is to amend the existing field in package.json instead.
@shirakaba Thanks, your solution works for me.
Add electron-winstaller to onlyBuiltDependencies in package.json, and run pnpm store prune; pnpm rebuild electron-winstaller
{
"pnpm": {
"onlyBuiltDependencies": [
"electron",
+ "electron-winstaller"
]
},
}
Thanks again.
@shirakaba , @wy-luke Thank you, I had the same exact issue and couldn't understand why. Your posts solved my issues!