Skip to content

System.ComponentModel.Win32Exception: The system cannot find the file specified when running on azure agent #3892

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

Open
3 tasks done
TiagoCastilhos opened this issue Mar 18, 2025 · 7 comments

Comments

@TiagoCastilhos
Copy link

TiagoCastilhos commented Mar 18, 2025

Pre-flight checklist

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project uses.
  • 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

  1. Create an electron application and push it to a repo on azure devops
  2. Configure squirrel maker
  3. 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.

@shirakaba
Copy link

Related issue: #3900

@TiagoCastilhos
Copy link
Author

@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

@shirakaba
Copy link

shirakaba commented Apr 4, 2025

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.

@shirakaba
Copy link

shirakaba commented Apr 5, 2025

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 Squirrel/Squirrel.Windows#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.

@shirakaba
Copy link

shirakaba commented Apr 5, 2025

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. 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 onlyBuiltDependenciesFile and neverBuiltDependencies are 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-winstaller to clear the side-effects cache and re-run the install script for that package.

@shirakaba
Copy link

shirakaba commented Apr 5, 2025

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.

@wy-luke
Copy link
Contributor

wy-luke commented Apr 26, 2025

@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.

wy-luke added a commit to wy-luke/forge that referenced this issue Apr 26, 2025
Add `electron-winstaller` in `onlyBuiltDependencies` when using pnpm.

Related issue: electron#3892
github-merge-queue bot pushed a commit that referenced this issue May 7, 2025
* fix: add electron-winstaller in onlyBuiltDependencies

Add `electron-winstaller` in `onlyBuiltDependencies` when using pnpm.

Related issue: #3892

* style: format

Co-authored-by: Kevin Cui <[email protected]>

---------

Co-authored-by: Kevin Cui <[email protected]>
Co-authored-by: Keeley Hammond <[email protected]>
Co-authored-by: Erick Zhao <[email protected]>
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