packager: EPERM: operation not permitted, lstat electron.zip in windows due to corporate proxy preventing download

Preflight Checklist

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project follows, as appropriate.
  • I have searched the issue tracker for a bug that matches the one I want to file, without success.

Issue Details

When trying to create an exe-File by using electron-packagr the following message gets displayed:

EPERM: operation not permitted, lstat 'C:\TEMP\electron-download-rCu75g\electron-v1.8.8-win32-x64.zip'

I run the following command: electron-packager . --overwrite --DEBUG=* --platform=win32 --arch=x64 --prune=true --out=release-builds --version-string.CompanyName=CE --version-string.FileDescription=CE --version-string.ProductName="MyApp" ``

  • Electron Packager Version: 14.0.0
  • Electron Version: 1.8.8
  • Operating System: Windows 7 SP1
  • Last Known Working Electron Packager version:: I do not know. It was 2018 when i last build that application but since then I deleted it and reinstalled.

Expected Behavior

To build the exe File

Actual Behavior

Builds nothing

To Reproduce

I am a restricted user because of company guidelines. Also I operate behind a corporate proxy.

Additional Information

This changes nothing of the output.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 3
  • Comments: 29 (6 by maintainers)

Most upvoted comments

Story I’ve finally solved this problem with a work around after running debug mode on the source code of two files under my-app\node_modules\electron\, these two files are install.js and index.js. After hours of digging, I really want to share this with you guys.

I am running windows 10 on my work laptop. I’ve ask my colleagues to try installing electron under corporate network, they can all run it with no problem. So at least in my case, this error is not caused by firewalls or other corporate network related setting.

Understand the Problem (please skip directly to solution is not interested) The nature of this problem as @kolomu suggested, is a connection problem from my computer to the github server hosting the electron zip file. There are two strategies to make it work without fixing the connection to the github server:

  1. swap zip file host server @kolomu
  2. manually satisfy files+location needs for electron to run properly (this comment)

I only explored solution2 because I am not familiar with building local host in solution1. If you can, by all means use solution1 because you can then reuse it for other apps without manually repeat solution2.

Steps for Solution2

  1. In terminal, under your-app\, run npm install electron. This will give you the well known ‘operation not permitted’ error. This is just to make sure you have the your-app\node_modules\electron directory. If you already have, skip this step.
  2. Add dist\ directory under your-app\node_modules\electron so you have your-app\node_modules\electron\dist\
  3. Download zip file of your preferred electron version from here, in my case is “electron-v7.1.3-win32-x64.zip”.
  4. Extract all contents from zip file under your-app\node_modules\electron\dist\. Make sure the contents are not in extra folder but directly under dist\. If it is done correctly, you should be able to find dist\electron.exe.
  5. Add path.txt file under your-app\node_modules\electron
  6. Add one line saying electron.exe in path.txt file and save. This is becasue at run time, your-app\node_modules\electron\index.js is reading from path.txt to get the executable name of electron, which is electron.exe.
  7. In terminal, go to your-app\, run npm start. Now your app should run and an electron window should show up if you are using the electron-quick-start as your app. You can find the app here. I would recommend starting with this demo app, because you know the app itself works, which isolates the electron installation problem.

Wish everyone good luck and please let me know if you have any questions.

Happy coding!

Had the same problem and did some debugging.

Turns out, if you set ELECTRON_GET_USE_PROXY then @electron/get uses global-agent as proxy lib. global-agent in turn uses the env variable GLOBAL_AGENT_HTTP_PROXY to determine the proxy address.

Setting both resolved the issue for me!

I have NodeJS 12.12.0, npm 6.11.3, electron 7.0.1, electron-packager 14.1.0, and @electron/get 1.6.0.

I have set HTTP_PROXY, HTTPS_PROXY, and ELECTRON_GET_USE_PROXY to http://<url>:<port> in both my system environment variables and a batch script I use to run the build command.

My build command looks something like this:

electron-packager . <name> --out dist --overwrite --platform win32 --arch x64

However, I’m still getting this error:

EPERM: operation not permitted, lstat 'C:\Users\<username>\AppData\Local\Temp\electron-download-rPBgGC\electron-v7.0.1-win32-x64.zip'

The directory C:\Users\<username>\AppData\Local\Temp\electron-download-rPBgGC is empty. Running the build command as admin results in the same error.

I have another project that’s using electron 4.2.12, electron-packager 13.1.1, and electron-download 4.1.1. It builds without error using a similar build command.

Update (November 5th, 2019):

I upgraded to electron 7.1.0 and now I’m getting this error during postinstall. It seems to be related.

(node:20640) UnhandledPromiseRejectionWarning: Error: EPERM: operation not permitted, lstat 'C:\Users\<username>\AppData\Local\Temp\electron-download-pTQppp\electron-v7.1.0-win32-ia32.zip'
(node:20640) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:20640) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

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 (instructions for Windows and non-Windows). Please include the stack trace if one exists.

  • Can you try with Electron Packager 13.1.1?

I give up 😃 I have the path specified and it still comes the error message.

electron-packager . --download.mirrorOptions.mirror=http://localhost:8082 --out=dist/win --platform=win32 --arch=x64

EPERM: operation not permitted, lstat 'C:\Users\###\AppData\Local\Temp\electron-download-DDMpyZ\electron-v7.1.1-win32-x64.zip'

Does somebody still have an idea?

Thanks

I’m getting the same error, I’m not behind a proxy.

Better proxy support was added to @electron/get, docs for this are currently in progress: https://github.com/electron/electron/pull/20780/files

Download the zip to the appropriate cache folder: https://github.com/electron/get#how-it-works