forge
forge copied to clipboard
[electron-forge make] EPERM: operation not permitted, rmdir.
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.
Electron Forge version
7.2.0
Electron version
28.0.0
Operating system
Windows 11 Home
Last known working Electron Forge version
No response
Expected behavior
Be able to use electron-forge make / npm without EPERM errors.
Actual behavior
I am attempting to follow the "Quick Start > Package and distribute your application" guide provided by the Electron documentation. However, I am encountering the following error: EPERM: operation not permitted, rmdir 'C:\Users\user\AppData\Local\Temp\electron-packager\tmp-u5kZtS\resources\app\node_modules.electron-vy9FvFgv\dist'.
Steps to reproduce
npm run make
or
npx electron-forge make
Additional information
I have explored various solutions to address this issue, including:
- Running the process both as an administrator and a regular user.
- Executing
npm cache clean --forceandnpm cache verify. - Changing the TEMP path to a location on a non-system drive.
- Rebooting the computer under different states.
- Attempting the use of
YARN, resulting in the same error. - Adjusting versions of
Node,NPM, andelectron-forgewith combinations such as:Node: v21.5.0, v20.10.0, v18.19.0, v9.11.2.NPM: v10.2.3, v4.x.x, v5.x.x.Electron-forge: v6.0.x.
To resolve the issue, I attempted to delete the empty folder created by electron-forge in the TEMP directory using rmdir "path" as specified in an error. However, I encountered the error Access is denied., being an administrator with the necessary permissions. Using rmdir /s /q "path" successfully removes a folder. I'm concerned that a library might be incorrectly using a command to delete a directory.
Facing same issue when using package command
Facing same issue when using
packagecommand
Yes, I have encountered a similar issue with package command too. electron-forge utilizes the system's temporary directory, and when trying to delete folders within it, it lacks the necessary permissions.
This is likely due to the outdated version of rimraf being used by electron-forge. I attempted to use the same version of the rimraf package globally as electron-forge when deleting a folder, and I encountered the same error that electron-forge was facing β being unable to delete the folder with EPERM error. However, when I updated rimraf from version 3.x.x to 5.0.5, the folder was successfully deleted.
Got it, but weird thing is that I have two apps running electron forge. One is still working fine but other started giving me issue suddenly. I guess after a windows update.
I checked rimraf version in both apps and it's same in both apps.
Also may I know how you updated the internal dependency rimraf
Got it, but weird thing is that I have two apps running electron forge. One is still working fine but other started giving me issue suddenly. I guess after a windows update. I checked
rimrafversion in both apps and it's same in both apps. Also may I know how you updated the internal dependencyrimraf
When I globally installed rimraf with the version matching that of electron-forge (3.X.X), I attempted to delete a folder that electron-forge couldn't delete, resulting in the same EPERM error. However, upon updating rimraf to the latest global version (5.0.5), I successfully removed the folder using rimraf <path>.
But manually removing folder is not working in my case. I thought it's the prePackage hook and I tried deleting it manually the whole temp electron-packager directory but electron-forge is failing then in the postPackage hook.
Any update on this issue? I am using WSL to package builds for now!!
Any update on this issue? I am using WSL to package builds for now!!
No updates.
Why the maintainers are not responding? It's been 3 weeks. π«‘
Why the maintainers are not responding? It's been 3 month.
I was having the same problem with EPERM in the %temp% folder with "@electron-forge/cli":"^7.4.0":
An unhandled rejection has occurred inside Forge:
Error: EPERM: operation not permitted, rmdir 'C:\temp\electron-packager\tmp-NmAfcr\resources\app'
I had created an app from scratch via wrapper as indicated in the documentation: npm init electron-app@latest my-app -- --template=webpack
I've tested all the suggested workarounds (cache clear, etc...) without effect, no matter how many times I delete the folder with error or run as administrator.
The only solution I had was to create an app manually with version 6 of @electron/forge:
npm install -g @electron-forge/[email protected]
npx electron-forge init --template=webpack
That way my app builds normally without errors:
PS C:\Users\xxxxxxx\Documents\GitHub\teste-electron2> npm run make
> [email protected] make
> electron-forge make
β Checking your system
β Loading configuration
β Resolving make targets
βΊ Making for the following targets: squirrel
β Running package command
β Preparing to package application
β Running packaging hooks
β Running generateAssets hook
β Running prePackage hook
β [plugin-webpack] Preparing native dependencies
β [plugin-webpack] Building webpack bundles
β Packaging application
β Packaging for x64 on win32 [2s]
β Running postPackage hook
β Running preMake hook
β Making distributables
β Making a squirrel distributable for win32/x64 [32s]
β Running postMake hook
βΊ Artifacts available at: C:\Users\xxxxxx\Documents\GitHub\teste-electron2\out\make
I hope it helps. My repo: https://github.com/AlencarGabriel/example-electron-with-fast-design
For some reason (without having changed anything) make stopped working. Even in the version that used to work.
What I realized is that the directory: %temp%\electron-packager\win32-x64\Appxxxxx\resources\app is created with some protection or limitation, that I can't even remove the folder by running a simple delete script via node:
All other files and folders are removed, except \app
I don't want to push it, but I think the problem might be Node.
I just changed remove to removeSync() in my example above and the folder was successfully removed.
I looked at the fs-extras repo (used in electron-forge) and I didn't see anything else between them, in the end it's a call to the Node default fs.
I played around with my node_modules and changed all the references from fs.remove() to fs.removeSync() in the electron-package folders, and magically the build worked correctly. π
What I still don't understand is why some repositories (using the same versions of dependencies) work and others don't, even on the same machine. And why it started happening out of the blue.
When should we expect an update for this?
I don't want to push it, but I think the problem might be Node.
I just changed remove to
removeSync()in my example above and the folder was successfully removed.I looked at the
fs-extrasrepo (used in electron-forge) and I didn't see anything else between them, in the end it's a call to the Node defaultfs.I played around with my
node_modulesand changed all the references fromfs.remove()tofs.removeSync()in theelectron-packagefolders, and magically the build worked correctly. πWhat I still don't understand is why some repositories (using the same versions of dependencies) work and others don't, even on the same machine. And why it started happening out of the blue.
Maybe it's a permission issue because you didn't run PowerShell as an administrator? It shouldn't be a Node.js problem.
I solved the issue by running the make command as an administrator.
I don't want to push it, but I think the problem might be Node. I just changed remove to
removeSync()in my example above and the folder was successfully removed. I looked at thefs-extrasrepo (used in electron-forge) and I didn't see anything else between them, in the end it's a call to the Node defaultfs. I played around with mynode_modulesand changed all the references fromfs.remove()tofs.removeSync()in theelectron-packagefolders, and magically the build worked correctly. π What I still don't understand is why some repositories (using the same versions of dependencies) work and others don't, even on the same machine. And why it started happening out of the blue.Maybe it's a permission issue because you didn't run PowerShell as an administrator? It shouldn't be a Node.js problem.
I solved the issue by running the make command as an administrator. `
@minikinl
I think that if it was a permission problem it should also happen with fs.removeSync(), but in this scenario I mentioned the problem only occurred with fs.remove()`.
Also getting this issue on Windows CI. The workaround was to downgrade Forge to 6.4.2.
UPDATE: Fixed properly now. It was caused by turborepo running two forge builds in parallel.
Also getting this issue on Windows CI. The workaround was to downgrade Forge to
6.4.2.UPDATE: Fixed properly now. It was caused by turborepo running two forge builds in parallel.
Would you be so kind to write a tutorial on how to do it?
Would you be so kind to write a tutorial on how to do it?
Sure - if you're using Turborepo and running multiple forge builds, ensure that the builds are run consecutively. You can do this with --concurrency=1, or by setting each forge build to depend on another. In my project there are two forge builds, one for CJS and one for ESM, they were running in parallel which resulted in this error, the fix was to make the CJS build dependent on the ESM build.
Had the same issue on previously working application, but using some of the info above from @AlencarGabriel I've got a workaround that allowed me to make the app. Possibly some Windows update has broken this functionality (I'm on Win11)?
For electron-forge v7.5.0
Edited two of the files in ..\node_modules\@electron\packager\dist\
platform.js and universal.js
Changed all references from the command fs_extra_1.default.remove to fs_extra_1.default.removeSync
Then re-run npm run make and it worked correctly.
Alternatively, if you're on electron-forge v6.x (or you want to downgrade with npm install @electron-forge/[email protected]), you need to edit three of the files in \node_modules\electron-packager\src
universal.js, platform.js & index.js
and replace fs.remove with fs.removeSync in all cases.
I am facing the same problem when running the package command.
I have Windows 10 and @electron-forge/cliβ:β^7.5.0.
First tried, as @VirtualColossus advised, changing fs_extra_1.default.remove to fs_extra_1.default.removeSync in the platform.js and universal.js files, but that didn't help.
And how I solved it in my case.
Thinking that the problem might be related to deleting temporary files, I went to C:\Users\SHTF\AppData\Local\Temp\electron-packager\tmp-oMtQDG\resources\app and found the last folder empty. I decided to manually delete the electron-packager folder and all its contents.
After that I ran the package command again and everything workedπ€.
The electron-packager folder appeared in the Temp folder again, but it was empty without tmp-oMtQDG\resources\app or similar.
I don't know why I had to delete it all manually. If anyone has any ideas, I will be glad to hear them.
same issue
Why the maintainers are not responding? It's been 3 month.
And it's been a year! The few apps that I'm currently running Forge on are able to package in CI on Electron Forge 7 with no issues. I currently don't have a repro case after running the package command on a fresh repo on Windows 11.
There might be an issue with your specific device setup that makes this hard to debug.
I upgraded the node version and then only it worked I tried all solutions provided in this thread but only upgradation of node version worked.