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\"
``
To build the exe File
Builds nothing
I am a restricted user because of company guidelines. Also I operate behind a corporate proxy.
This changes nothing of the output.
馃憢 Thanks for opening your first issue here! If you have a question about using Electron Packager, read the support docs. If you're reporting a 馃悶 bug, please make sure you include steps to reproduce it. Development and issue triage is community-driven, so please be patient and we will get back to you as soon as we can.
To help make it easier for us to investigate your issue, please follow the contributing guidelines.
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?
Thanks for your help so far.
Here is the console output with debug option on:
D:\dev\projects\myapp_all\myapp-electron>electron-packager . --overwrite --platform=win32 --arch=x64 --prune=true --out=release-builds --version-string.CompanyName=CE --version-string.FileDescription=CE --version-string.ProductName=\"myapp\" > log.txt
electron-packager Electron Packager 14.0.0
electron-packager Node v9.4.0
electron-packager Host Operating system: win32 (x64) +0ms
electron-packager Packager Options: {"_":["."],"deref-symlinks":true,"derefSymlinks":true,"download":{"rejectUnauthorized":true,"reject-unauthorized":true},"junk":true,"prune":true,"overwrite":true,"platform":"win32","arch":"x64","out":"release-builds","version-string":{"CompanyName":"CE","FileDescription":"CE","ProductName":"myapp"},"versionString":{"companyName":"CE","fileDescription":"CE","productName":"myapp"},"dir":".","protocols":[]} +2ms
electron-packager Target Platforms: win32 +0ms
electron-packager Target Architectures: x64 +1ms
get-package-info Getting props: [ [ 'productName', 'name' ],
'version',
[ 'dependencies.electron',
'devDependencies.electron',
'dependencies.electron-nightly',
'devDependencies.electron-nightly',
'dependencies.electron-prebuilt-compile',
'devDependencies.electron-prebuilt-compile',
'dependencies.electron-prebuilt',
'devDependencies.electron-prebuilt' ],
'author' ] +0ms
get-package-info Looking up starting from directory: D:\dev\projects\myapp_all\myapp-electron +2ms
get-package-info Result so far: { values: {}, source: {} } +0ms
get-package-info Checking props in package.json found at: D:\dev\projects\myapp_all\myapp-electron\package.json +5ms
get-package-info Found prop: [ 'productName', 'name' ] +0ms
get-package-info Found prop: version +0ms
get-package-info Found prop: [ 'dependencies.electron',
'devDependencies.electron',
'dependencies.electron-nightly',
'devDependencies.electron-nightly',
'dependencies.electron-prebuilt-compile',
'devDependencies.electron-prebuilt-compile',
'dependencies.electron-prebuilt',
'devDependencies.electron-prebuilt' ] +1ms
get-package-info Couldn't find prop: author +1ms
get-package-info Not all props satisfied, looking for parent package.json +0ms
get-package-info Getting props: [ 'author' ] +1ms
get-package-info Looking up starting from directory: D:\dev\projects\myapp_all +0ms
get-package-info Result so far: { values:
{ productName: 'myapp',
name: 'myapp',
version: '1.0.2',
'dependencies.electron': '^1.8.8',
'devDependencies.electron': '^1.8.8',
'dependencies.electron-nightly': '^1.8.8',
'devDependencies.electron-nightly': '^1.8.8',
'dependencies.electron-prebuilt-compile': '^1.8.8',
'devDependencies.electron-prebuilt-compile': '^1.8.8',
'dependencies.electron-prebuilt': '^1.8.8',
'devDependencies.electron-prebuilt': '^1.8.8' },
source:
{ productName:
{ src: 'D:\\dev\\projects\\myapp_all\\myapp-electron\\package.json',
pkg: [Object],
prop: 'name' },
name:
{ src: 'D:\\dev\\projects\\myapp_all\\myapp-electron\\package.json',
pkg: [Object],
prop: 'name' },
version:
{ src: 'D:\\dev\\projects\\myapp_all\\myapp-electron\\package.json',
pkg: [Object],
prop: 'version' },
'dependencies.electron':
{ src: 'D:\\dev\\projects\\myapp_all\\myapp-electron\\package.json',
pkg: [Object],
prop: 'devDependencies.electron' },
'devDependencies.electron':
{ src: 'D:\\dev\\projects\\myapp_all\\myapp-electron\\package.json',
pkg: [Object],
prop: 'devDependencies.electron' },
'dependencies.electron-nightly':
{ src: 'D:\\dev\\projects\\myapp_all\\myapp-electron\\package.json',
pkg: [Object],
prop: 'devDependencies.electron' },
'devDependencies.electron-nightly':
{ src: 'D:\\dev\\projects\\myapp_all\\myapp-electron\\package.json',
pkg: [Object],
prop: 'devDependencies.electron' },
'dependencies.electron-prebuilt-compile':
{ src: 'D:\\dev\\projects\\myapp_all\\myapp-electron\\package.json',
pkg: [Object],
prop: 'devDependencies.electron' },
'devDependencies.electron-prebuilt-compile':
{ src: 'D:\\dev\\projects\\myapp_all\\myapp-electron\\package.json',
pkg: [Object],
prop: 'devDependencies.electron' },
'dependencies.electron-prebuilt':
{ src: 'D:\\dev\\projects\\myapp_all\\myapp-electron\\package.json',
pkg: [Object],
prop: 'devDependencies.electron' },
'devDependencies.electron-prebuilt':
{ src: 'D:\\dev\\projects\\myapp_all\\myapp-electron\\package.json',
pkg: [Object],
prop: 'devDependencies.electron' } } } +0ms
get-package-info Couldn't find any more package.json files +3ms
electron-packager Inferring application name from name in D:\dev\projects\myapp_all\myapp-electron\package.json +0ms
electron-packager Inferring appVersion from version in D:\dev\projects\myapp_all\myapp-electron\package.json +0ms
electron-packager Inferring target Electron version from electron in D:\dev\projects\myapp_all\myapp-electron\package.json +3ms
electron-packager Application name: myapp +17ms
electron-packager Target Electron version: 1.8.8 +0ms
electron-packager Ignored path regular expressions: [ '/\\.git($|/)', '/node_modules/\\.bin($|/)', '\\.o(bj)?$' ] +0ms
electron-packager Downloading Electron with options {"rejectUnauthorized":true,"reject-unauthorized":true,"platform":"win32","arch":"x64","version":"1.8.8","artifactName":"electron"} +0ms
@electron/get:index Checking the cache for electron-v1.8.8-win32-x64.zip +0ms
@electron/get:index Cache miss +1ms
@electron/get:index Downloading https://github.com/electron/electron/releases/download/v1.8.8/electron-v1.8.8-win32-x64.zip to C:\TEMP\electron-download-SU0IRn\electron-v1.8.8-win32-x64.zip with options: undefined +37ms
I think the problem is in downloading electron. Because the corporate proxy won't allow that so easily.
Most of the time I can manually download the file and point the application to it.
Is this here possible too?
With the debug log I thought of downloading the file and putting it in there. However the directory name in temp changes everytime I start the build process.
Download the zip to the appropriate cache folder: https://github.com/electron/get#how-it-works
Was this resolved? how do i determine which is the appropriate cache folder?
Click the link and choose the operating system you're running Electron Packager on (not the target).
EDIT: could the problem be due to not having correct privileges to create symbolic links? I'm certain most group policies would have that disabled outside of true admins. Not sure what a workaround for that would be if that is true
I'm having the same exact issue. The zip is in the appropriate cache.
I can see the temp electron download folder created, the image of the zip file appears with file size 0kb, then a few seconds later we get the lstat error message.
I tried from my personal machine and it works fine, but it does not work on my company laptop. I can install packages just fine, but for some reason the packager can't get past this part.
I am facing a similar issue as @kolomu . Here is what I get when i run it on the mac (behind corporate proxy):
$ electron-packager . my-app-mac --overwrite --platform=darwin --arch=x64 --prune=true --out=packaged
electron-packager Electron Packager 14.0.5
electron-packager Node v10.15.3
electron-packager Host Operating system: darwin 18.5.0 (x64) +0ms
electron-packager Packager Options: {"_":[".","my-app-mac"],"deref-symlinks":true,"derefSymlinks":true,"download":{"rejectUnauthorized":true,"reject-unauthorized":true},"junk":true,"prune":true,"overwrite":true,"platform":"darwin","arch":"x64","out":"packaged","dir":".","name":"my-app-mac","protocols":[]} +1ms
electron-packager Target Platforms: darwin +1ms
electron-packager Target Architectures: x64 +0ms
electron-packager Inferring appVersion from version in /Users/kachauba/Documents/code/my-app/package.json +0ms
electron-packager Inferring target Electron version from electron in /Users/kachauba/Documents/code/my-app/package.json +4ms
electron-packager Application name: my-app-mac +12ms
electron-packager Target Electron version: 6.0.2 +0ms
electron-packager Ignored path regular expressions: [ '/\\.git($|/)', '/node_modules/\\.bin($|/)', '\\.o(bj)?$' ] +0ms
electron-packager Downloading Electron with options {"rejectUnauthorized":true,"reject-unauthorized":true,"platform":"darwin","arch":"x64","version":"6.0.2","artifactName":"electron"} +0ms
connect ETIMEDOUT 192.30.253.113:443
I did some digging and this is what I understand:
downloadArtifact is a function from @electron/get and under the hood, i feel it is getting stuck here: https://github.com/electron/get/blob/master/src/GotDownloader.ts#L15got.stream is a function from sindresorhus/got package but i have no idea how to make it proxy awareWhat all have I tried unsuccessfully?
@malept / others - any other recommendations?
Downloading the electron zip (as recommended by @malept).However, that does not work as electron-packager creates a random directory-name and so, i don't know what should be the exact directory name where I download and extract the zip file in
There was a recent change to @electron/get (https://github.com/electron/get/pull/113) where zip files get put in a subfolder of the standard cache dir, named for the URL that is the source. Electron Packager does not create a random directory name for the cache.
any other recommendations?
As a last resort, you may have to write your own CLI wrapper around the electron-packager module, and pass the relevant proxy code from https://github.com/sindresorhus/got#proxies to download.downloadOptions.
I am facing a similar issue as @kolomu . Here is what I get when i run it on the mac (behind corporate proxy):
$ electron-packager . my-app-mac --overwrite --platform=darwin --arch=x64 --prune=true --out=packaged electron-packager Electron Packager 14.0.5 electron-packager Node v10.15.3 electron-packager Host Operating system: darwin 18.5.0 (x64) +0ms electron-packager Packager Options: {"_":[".","my-app-mac"],"deref-symlinks":true,"derefSymlinks":true,"download":{"rejectUnauthorized":true,"reject-unauthorized":true},"junk":true,"prune":true,"overwrite":true,"platform":"darwin","arch":"x64","out":"packaged","dir":".","name":"my-app-mac","protocols":[]} +1ms electron-packager Target Platforms: darwin +1ms electron-packager Target Architectures: x64 +0ms electron-packager Inferring appVersion from version in /Users/kachauba/Documents/code/my-app/package.json +0ms electron-packager Inferring target Electron version from electron in /Users/kachauba/Documents/code/my-app/package.json +4ms electron-packager Application name: my-app-mac +12ms electron-packager Target Electron version: 6.0.2 +0ms electron-packager Ignored path regular expressions: [ '/\\.git($|/)', '/node_modules/\\.bin($|/)', '\\.o(bj)?$' ] +0ms electron-packager Downloading Electron with options {"rejectUnauthorized":true,"reject-unauthorized":true,"platform":"darwin","arch":"x64","version":"6.0.2","artifactName":"electron"} +0ms connect ETIMEDOUT 192.30.253.113:443I did some digging and this is what I understand:
- Looks like it is reaching this line in electron-packager: https://github.com/electron/electron-packager/blob/master/src/download.js#L35
downloadArtifactis a function from @electron/get and under the hood, i feel it is getting stuck here: https://github.com/electron/get/blob/master/src/GotDownloader.ts#L15got.streamis a function from sindresorhus/got package but i have no idea how to make it proxy awareWhat all have I tried unsuccessfully?
- Downloading the electron zip (as recommended by @malept).However, that does not work as electron-packager creates a random directory-name and so, i don't know what should be the exact directory name where I download and extract the zip file in
- Setting HTTP and HTTPS proxy in the global .npmrc
- Setting HTTP and HTTPS proxy in the project .npmrc
- Setting these environment variables: HTTP_PROXY, HTTPS_PROXY, GLOBAL_AGENT_HTTP_PROXY, GLOBAL_AGENT_HTTPS_PROXY (as suggested here: https://github.com/sindresorhus/got#proxies)
@malept / others - any other recommendations?
I was able to get it to work by using electron-packager-interactive. it must use a different mechanism, but I didn't have time to dig further into it. see if it could work for you?
--download.cacheRoot seems to be ignored at least in @electron/[email protected]
My electron-packager always tries to go download electron on my offline machine with this dependency version. This worked fine in @electron/[email protected].
@a4chet if cacheRoot is not working for you, please file a bug at the @electron/get issue tracker. That is unrelated to this bug.
Hi, if still someone struggles with this problem here is my current workaround :
$env:DEBUG='electron-packager';electron-packager . npm i -g http-serverhttp-serverelectron-packager . --download.mirrorOptions.mirror=http://localhost:8080Now it should build.
Hi, if still someone struggles with this problem here is my current workaround :
- determine what file electron-packager is downloading: in Powershell:
$env:DEBUG='electron-packager';electron-packager .- Download the required file manually (select the right version (zip) + SHASUMS256.txt)
- Install http-server to serve the file manually
npm i -g http-server- create a version folder e.g. v1.8.8 and copy the downloaded zip file + checksum.txt file in it
- switch to that directory and start server with
http-server- finally build the electron-app by providing the following mirror:
electron-packager . --download.mirrorOptions.mirror=http://localhost:8080Now it should build.
I do what you said above, but it still failed.it reported "EPERM: operation not permitted, lstat 'C:\Users\y\AppData\Local\Temp\electron-download-nprkeq\electron-v6.0.12-win32-x64.zip'"
It seems like it still tries to download the file remotely. Did you start the http server with the zip file and provided the download.mirrorOptions.mirror which is pointing to localhost? What electron-packager version are you using? I installed the latested version with npm i -g electron-packager
It seems like it still tries to download the file remotely. Did you start the http server with the zip file and provided the download.mirrorOptions.mirror which is pointing to localhost? What electron-packager version are you using? I installed the latested version with
npm i -g electron-packager
I did it again and it worked success!! Thank you so much!love you
Better proxy support was added to @electron/get, docs for this are currently in progress: https://github.com/electron/electron/pull/20780/files
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.
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.
I'm getting the same error, I'm not behind a proxy.
Had the same error on my company laptop. I could fix it by disconnecting from the company network and using my private mobile hotspot.
Hi, if still someone struggles with this problem here is my current workaround :
- determine what file electron-packager is downloading: in Powershell:
$env:DEBUG='electron-packager';electron-packager .- Download the required file manually (select the right version (zip) + SHASUMS256.txt)
- Install http-server to serve the file manually
npm i -g http-server- create a version folder e.g. v1.8.8 and copy the downloaded zip file + checksum.txt file in it
- switch to that directory and start server with
http-server- finally build the electron-app by providing the following mirror:
electron-packager . --download.mirrorOptions.mirror=http://localhost:8080Now it should build.
Tried what you suggested and I still get "EPERM: operation not permitted, lstat 'C:\Users\y\AppData\Local\Temp\electron-download-nprkeq\electron-v6.0.12-win32-x64.zip'"
this is my build command :
electron-packager . --download.mirrorOptions.mirror=http://localhost:8080/electron-v6.0.12-win32-x64.zip --out=dist/win --platform=win32 --arch=x64
do you have any suggestions on what the problem might be?
yep the mirror should not include the full url but just the hostname
yep the mirror should not include the full url but just the hostname
tried it both ways without any luck
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 have the same problem, but I can access github to download the package through. So I think it is not due to proxy setting (I have set ELECTRON_GET_USE_PROXY already). But I still have the same problem.
I tried also using the local web server approach but without luck.
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!
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:
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
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.dist\ directory under your-app\node_modules\electron so you have your-app\node_modules\electron\dist\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. path.txt file under聽your-app\node_modules\electronelectron.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.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!
For me, specify electron version in command line
( warning! when you launch cmd "electron .", it is possible that he system use path variable "/appData/Roaming/npm/" cause of that, the system used a different version of electron than the version in your current project)
Example :
electron-packager . electron-app-asar --electron-version 7.1.4 --platform=win32 --arch=ia32 --asar --overwrite --app-copyright=\"Copyright (c) 2019 The Client. All rights reserved.\""
Most helpful comment
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 areinstall.jsandindex.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:
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
your-app\, runnpm install electron. This will give you the well known 'operation not permitted' error. This is just to make sure you have theyour-app\node_modules\electrondirectory. If you already have, skip this step.dist\directory underyour-app\node_modules\electronso you haveyour-app\node_modules\electron\dist\your-app\node_modules\electron\dist\. Make sure the contents are not in extra folder but directly underdist\. If it is done correctly, you should be able to finddist\electron.exe.path.txtfile under聽your-app\node_modules\electronelectron.exeinpath.txtfile and save. This is becasue at run time,your-app\node_modules\electron\index.jsis reading frompath.txtto get the executable name of electron, which iselectron.exe.your-app\, runnpm start. Now your app should run and an electron window should show up if you are using theelectron-quick-startas 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!