Skip to content
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

EPERM: operation not permitted (rmdir) when using prune #597

Closed
3 tasks done
JAA17 opened this issue Feb 19, 2017 · 23 comments
Closed
3 tasks done

EPERM: operation not permitted (rmdir) when using prune #597

JAA17 opened this issue Feb 19, 2017 · 23 comments
Labels
bug 🐛 build-host:windows Running Electron Packager on Windows needs info Issue reporter needs to provide more information for maintainers to take action

Comments

@JAA17
Copy link

JAA17 commented Feb 19, 2017

  • 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 an issue that matches the one I want to file, without success.

[Edited due to spelling error]

I am getting an EPERM error related to rmdir.

ERR! Error: EPERM: operation not permitted, rmdir c:\Users\Jon\Desktop\Test\distwin32a\mytest1-win32-x64\resources\app\node_modules

My command line is:

npm run build-win32

My script is:

"build-win32": "electron-packager . --electron-version 1.4.15 --tmpdir=false --platform win32 --icon ./assets/icon.ico --out ./distwin32a --overwrite"

My package.json is:

    {
  "name": "mytest1",
  "version": "1.0.0",
  "description": "MyTest2",
  "main": "main.js",
  "scripts": {
    "start": "electron main.js",
	"build-all": "electron-packager . --electron-version 1.4.15 --tmpdir=false --platform all --icon ./assets/icon --out ./dist",
	"build-win32": "electron-packager . --electron-version 1.4.15 --tmpdir=false --platform win32 --icon ./assets/icon.ico --out ./distwin32a --overwrite",
	"build-linux": "electron-packager . --electron-version 1.4.15 --tmpdir=false --platform linux --icon ./assets/background.png --out ./distlinux --overwrite",
	"build-osx": "electron-packager . --electron-version 1.4.15 --tmpdir=false --platform darwin --icon ./assets/icon.icns --out ./distdarwin --overwrite"
  },
  "private": true,
  "build": {
    "appId": "mycompany.myproduct"
  },
  "keywords": [
    "Stuff",
    "Stuff"
  ],
  "author": "JAA17",
  "license": "SEE LICENSE IN LICENSE.TXT",
  "devDependencies": {
    "electron-packager": "^8.5.1"
  }
}

The only thing I have in the background is Visual Studio where I do my code editing.

@malept malept added bug 🐛 build-host:windows Running Electron Packager on Windows needs info Issue reporter needs to provide more information for maintainers to take action labels Feb 19, 2017
@malept
Copy link
Member

malept commented Feb 19, 2017

Is this the path in the error verbatim?

c:\Users\Jon\Desktop\Test\distwin32a\mytest1-win32-x64\resources\app\node_modues

I ask because normally it's named node_modules.

@malept malept changed the title ERR! Error: EPERM: operation not permitted, rmdir EPERM: operation not permitted, rmdir Feb 19, 2017
@JAA17
Copy link
Author

JAA17 commented Feb 19, 2017

Sorry, you are right it is node_modules. I will correct the original post.

@malept
Copy link
Member

malept commented Feb 19, 2017

Just so I'm clear, does the folder actually exist? If so, what are the permissions on it?

@JAA17
Copy link
Author

JAA17 commented Feb 19, 2017

Everything exists up to:

c:\Users\Jon\Desktop\Test\distwin32a\mytest1-win32-x64\resources\app\

The node_modules does not exist in that folder. c:\Users\Jon\Desktop\Test\distwin32a\mytest1-win32-x64\resources\app\ appears to have everything else from my c:\Users\Jon\Desktop\Test\ folder where I execute the command line npm run build-win32.

BUT, in c:\Users\Jon\Desktop\Test\ I also have node_modules. So it appears node_modules should be copied from c:\Users\Jon\Desktop\Test\ to c:\Users\Jon\Desktop\Test\distwin32a\mytest1-win32-x64\resources\app\, but does not actually do it. So maybe when it thinks it has to delete node_modules in c:\Users\Jon\Desktop\Test\distwin32a\mytest1-win32-x64\resources\app\ it cannot find it to delete? I am just guessing.

@malept
Copy link
Member

malept commented Feb 20, 2017

What happens when you remove --overwrite and get rid of the out directories manually?

@JAA17
Copy link
Author

JAA17 commented Feb 20, 2017

Hi, sorry for the delay. I am on UK time.

I have done what you have asked and there is still a problem, but a different one. It is the one that the other guy had in the other thread where I originally raised this issue.

So I deleted c:\Users\Jon\Desktop\Test\distwin32a manually in Windows File Manager and removed it from the Recycle Bin. I then removed --overwrite from the script resulting in the script being:

"build-win32a": "electron-packager . --electron-version 1.4.15 --tmpdir=false --platform win32 --icon ./assets/icon.ico --out ./distwin32a"

The Error is now:

Packaging app for platform win32 x64 using electron v1.4.15 rcedit.exe failed with exit code 1. Fatal error: Unable to commit changes

@malept
Copy link
Member

malept commented Feb 20, 2017

So you can only reproduce the EPERM error when you use --overwrite?

@JAA17
Copy link
Author

JAA17 commented Feb 21, 2017

Hi malept. I have been trying what you asked this morning (Midday UK time) for the past half hour and am getting different results.

At present it always fails when I have the --overwrite argument with an EPERM error of some sort. Mostly it is EPERM rmdir, however I rarely I also get a EPERM lstat error.

At the moment when I remove --overwrite there are two results.

It WORKS when I manually remove the distwin32 directory before I run npm run build-win32.

It IS PRESENTLY WORKING (but FAILED about half hour ago) when I do not manually remove the `distwin32' directory.

@malept malept changed the title EPERM: operation not permitted, rmdir EPERM: operation not permitted (rmdir) when using --overwrite Feb 21, 2017
@malept
Copy link
Member

malept commented Feb 21, 2017

I have updated the issue summary accordingly.

@malept
Copy link
Member

malept commented Feb 27, 2017

Just for completeness's sake, could you provide full backtrace when you run electron-packager . --electron-version 1.4.15 --tmpdir=false --platform win32 --icon ./assets/icon.ico --out ./distwin32a --overwrite without using npm run build-win32. An example of a backtrace is in the issue summary of #598, after the line that says Error: ENOENT: no such file or directory. I suspect this line is the problem: https://github.com/electron-userland/electron-packager/blob/16752bdbb5fe987a9a9f15e120b85f3863168144/index.js#L201

If that is the case, the problem is most likely in the fs-extra module, which defines fs.remove.

@JAA17
Copy link
Author

JAA17 commented Feb 27, 2017

I have not touched this since I last heard from you. The first time I ran the command, I did not check to see if the distribution files were there or not. I got the unusual error.

  1. I do not know if the distribution directories were there or not and ran the command: electron-packager . --electron-version 1.4.15 --tmpdir=false --platform win32 --icon ./assets/icon.ico --out ./distwin32a --overwrite

I got the following rare lstat error:

Packaging app for platform win32 x64 using electron v1.4.15
Command failed: npm prune --production
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "prune" "--production"
npm ERR! node v6.9.5
npm ERR! npm  v3.10.10
npm ERR! path C:\Users\Jon\Desktop\Test\distwin32a\mytest1-win32-x64\resources\app\node_modules
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall lstat

npm ERR! Error: EPERM: operation not permitted, lstat 'C:\Users\Jon\Desktop\Test\distwin32a\mytest1-win32-x64\resources\app\node_modules'
npm ERR!     at Error (native)
npm ERR!  { Error: EPERM: operation not permitted, lstat 'C:\Users\Jon\Desktop\Test\distwin32a\mytest1-win32-x64\resources\app\node_modules'
npm ERR!     at Error (native)
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'lstat',
npm ERR!   path: 'C:\\Users\\Jon\\Desktop\\Test\\distwin32a\\mytest1-win32-x64\\resources\\app\\node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\Jon\Desktop\Test\distwin32a\mytest1-win32-x64\resources\app\npm-debug.log
  1. Doing absolutely nothing, just running the command again: electron-packager . --electron-version 1.4.15 --tmpdir=false --platform win32 --icon ./assets/icon.ico --out ./distwin32a --overwrite

I got a success!!!:

Packaging app for platform win32 x64 using electron v1.4.15
Wrote new app to distwin32a\mytest1-win32-x64
  1. I manually deleted the distribution directories (in File Manager) and ran your requested command: electron-packager . --electron-version 1.4.15 --tmpdir=false --platform win32 --icon ./assets/icon.ico --out ./distwin32a --overwrite

I get the error:

Packaging app for platform win32 x64 using electron v1.4.15
Command failed: npm prune --production
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "prune" "--production"
npm ERR! node v6.9.5
npm ERR! npm  v3.10.10
npm ERR! path C:\Users\Jon\Desktop\Test\distwin32a\mytest1-win32-x64\resources\app\node_modules
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rmdir

npm ERR! Error: EPERM: operation not permitted, rmdir 'C:\Users\Jon\Desktop\Test\distwin32a\mytest1-win32-x64\resources\app\node_modules'
npm ERR!     at Error (native)
npm ERR!  { Error: EPERM: operation not permitted, rmdir 'C:\Users\Jon\Desktop\Test\distwin32a\mytest1-win32-x64\resources\app\node_modules'
npm ERR!     at Error (native)
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'rmdir',
npm ERR!   path: 'C:\\Users\\Jon\\Desktop\\Test\\distwin32a\\mytest1-win32-x64\\resources\\app\\node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\Jon\Desktop\Test\distwin32a\mytest1-win32-x64\resources\app\npm-debug.log
  1. I then did NOT delete the distribution directories and ran the same command: : electron-packager . --electron-version 1.4.15 --tmpdir=false --platform win32 --icon ./assets/icon.ico --out ./distwin32a --overwrite

I get the error:

Packaging app for platform win32 x64 using electron v1.4.15
Command failed: npm prune --production
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "prune" "--production"
npm ERR! node v6.9.5
npm ERR! npm  v3.10.10
npm ERR! path C:\Users\Jon\Desktop\Test\distwin32a\mytest1-win32-x64\resources\app\node_modules
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rmdir

npm ERR! Error: EPERM: operation not permitted, rmdir 'C:\Users\Jon\Desktop\Test\distwin32a\mytest1-win32-x64\resources\app\node_modules'
npm ERR!     at Error (native)
npm ERR!  { Error: EPERM: operation not permitted, rmdir 'C:\Users\Jon\Desktop\Test\distwin32a\mytest1-win32-x64\resources\app\node_modules'
npm ERR!     at Error (native)
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'rmdir',
npm ERR!   path: 'C:\\Users\\Jon\\Desktop\\Test\\distwin32a\\mytest1-win32-x64\\resources\\app\\node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\Jon\Desktop\Test\distwin32a\mytest1-win32-x64\resources\app\npm-debug.log

I hope this helps. I am sorry the results do not seem to have a great deal of consistency.

@malept malept changed the title EPERM: operation not permitted (rmdir) when using --overwrite EPERM: operation not permitted (rmdir) when using prune Feb 27, 2017
@malept
Copy link
Member

malept commented Feb 27, 2017

OK, so this isn't about --overwrite, it's about --prune. According to your output, npm prune --production can't complete (which removes devDependencies from your bundled Electron app). Could you please try removing the node_modules folder from C:\Users\Jon\Desktop\Test, running npm install as a normal user (not Administrator), and try running the electron-packager command again?

@JAA17
Copy link
Author

JAA17 commented Feb 28, 2017

Could you please try removing the node_modules folder from C:\Users\Jon\Desktop\Test, running npm install as a normal user (not Administrator), and try running the electron-packager command again?

I have only one account on this PC, which obviously is admin. I do not want to create another account as I did so when I first got the pc and ultimately had to do a reinstall when it would not fully delete the non-admin account.

Is there any way of doing this without creating a new non-admin account?

@malept
Copy link
Member

malept commented Feb 28, 2017

If you only have one account, then are you running npm install with elevated permissions or something similar? I'm trying to figure out why you're getting that error. In any event, wipe out node_modules and reinstall it.

@JAA17
Copy link
Author

JAA17 commented Feb 28, 2017

OK, I have done the following in my only account on my PC.

  1. I delete the distribution folder and the node_modules in C:\Users\Jon\Desktop\Test

  2. I ran npm install in the command prompt in my directory C:\Users\Jon\Desktop\Test which created the node_modules again.

  3. I ran electron-packager . --electron-version 1.4.15 --tmpdir=false --platform win32 --icon ./assets/icon.ico --out ./distwin32a --overwrite in the command prompt in C:\Users\Jon\Desktop\Test and got the following error:

Packaging app for platform win32 x64 using electron v1.4.15
Command failed: npm prune --production
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "prune" "--production"
npm ERR! node v6.9.5
npm ERR! npm  v3.10.10
npm ERR! path C:\Users\Jon\Desktop\Test\distwin32a\mytest1-win32-x64\resources\app\node_modules
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rmdir

npm ERR! Error: EPERM: operation not permitted, rmdir 'C:\Users\Jon\Desktop\Test\distwin32a\mytest1-win32-x64\resources\app\node_modules'
npm ERR!     at Error (native)
npm ERR!  { Error: EPERM: operation not permitted, rmdir 'C:\Users\Jon\Desktop\Test\distwin32a\mytest1-win32-x64\resources\app\node_modules'
npm ERR!     at Error (native)
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'rmdir',
npm ERR!   path: 'C:\\Users\\Jon\\Desktop\\Test\\distwin32a\\mytest1-win32-x64\\resources\\app\\node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\Jon\Desktop\Test\distwin32a\mytest1-win32-x64\resources\app\npm-debug.log
  1. I had a look in C:\Users\Jon\Desktop\Test\distwin32a\mytest1-win32-x64. An executable was there with a default name, but it did not have my icon attached to it. The program ran correctly showing my hello world program.

  2. Without doing anything else, keeping both node_modules and the distributable directories in place I again ran 'I ran electron-packager . --electron-version 1.4.15 --tmpdir=false --platform win32 --icon ./assets/icon.ico --out ./distwin32a --overwrite in the command prompt in C:\Users\Jon\Desktop\Test.

This time it succeeded.

  1. I looked in the distributable directories and found mytest1.exe was there with the correct icon attached to it.

  2. Without doing anything I then ran electron-packager . --electron-version 1.4.15 --tmpdir=false --platform win32 --icon ./assets/icon.ico --out ./distwin32a --overwrite in the command prompt in C:\Users\Jon\Desktop\Test again.

This time it failed with the error:

Packaging app for platform win32 x64 using electron v1.4.15
Command failed: npm prune --production
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "prune" "--production"
npm ERR! node v6.9.5
npm ERR! npm  v3.10.10
npm ERR! path C:\Users\Jon\Desktop\Test\distwin32a\mytest1-win32-x64\resources\app\node_modules
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rmdir

npm ERR! Error: EPERM: operation not permitted, rmdir 'C:\Users\Jon\Desktop\Test\distwin32a\mytest1-win32-x64\resources\app\node_modules'
npm ERR!     at Error (native)
npm ERR!  { Error: EPERM: operation not permitted, rmdir 'C:\Users\Jon\Desktop\Test\distwin32a\mytest1-win32-x64\resources\app\node_modules'
npm ERR!     at Error (native)
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'rmdir',
npm ERR!   path: 'C:\\Users\\Jon\\Desktop\\Test\\distwin32a\\mytest1-win32-x64\\resources\\app\\node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\Jon\Desktop\Test\distwin32a\mytest1-win32-x64\resources\app\npm-debug.log
  1. I repeated 7 exactly the same, but this time it succeeded.

  2. I manually deleted the distributable directory in C:\Users\Jon\Desktop\Test' and ran electron-packager . --electron-version 1.4.15 --tmpdir=false --platform win32 --icon ./assets/icon.ico --out ./distwin32a --overwritein the command prompt inC:\Users\Jon\Desktop\Test` again.

This time it succeeded.

  1. Without doing anything I immediately ran C:\Users\Jon\Desktop\Test' and ran electron-packager . --electron-version 1.4.15 --tmpdir=false --platform win32 --icon ./assets/icon.ico --out ./distwin32a --overwritein the command prompt inC:\Users\Jon\Desktop\Test` again.

It succeeded once more.

  1. I repeated 9. It succeeded again.

  2. I repeated 10. It succeeded again.

(Note: there was about a 45 minute gap between steps 7 and 8 - I had my tea.)

@malept
Copy link
Member

malept commented Feb 28, 2017

Could you check the permissions of the folder C:\Users\Jon\Desktop\Test\distwin32a\mytest1-win32-x64\resources\app\node_modules? Is there anything special about it?

Also, This has become more of an NPM problem than an Electron Packager problem, I think. Could you search in the NPM issue tracker for EPERM and npm prune on Windows?

@JAA17
Copy link
Author

JAA17 commented Mar 1, 2017

When the error occurs node_modules does not exist. Is it trying to delete something that is not there? Is it deleting it first time correctly, then trying to delete it again when it is not there so throwing an error?

I have had a look in the NPM issue tracker and cannot see anything on these lines.

@malept
Copy link
Member

malept commented Mar 1, 2017

In order to debug your problem further, we need a minimal testcase to reproduce your problem. Using the electron-quick-start repository as a base, could you please create a minimal Electron app that illustrates the issue you described, and post a link to it here?

@JAA17
Copy link
Author

JAA17 commented Mar 1, 2017

A zip file:
HelloWorld.zip

@malept
Copy link
Member

malept commented Mar 8, 2017

I can't reproduce this on Linux. I've run both build-linux and build-osx repeatedly using your zipped app and did not get the rmdir error you experienced. I don't have a Windows environment, so this is difficult for me to debug further.

@malept malept added the help wanted Needs a contributor from the community label Mar 8, 2017
@jacobq
Copy link

jacobq commented Mar 10, 2017

@JAA17 I downloaded the HelloWorld.zip you provided and tried building it on a Windows 10 Pro system using node 6.x. I tried using git/bash shell as well as cmd.exe shell both as my normal user and running with elevated / administrator privileges. I tried deleting the files using Windows Explorer and leaving them there. In all cases the build succeeded without any errors. Are you still experiencing the problem? If so, I suspect it may be a system-specific problem, which would require a bit more detailed troubleshooting (e.g. using Process Monitor, looking through installed software and/or Windows settings, etc.), and furthermore it's probably more related to node/npm than to electron-packager. You might want to try some of the solutions others have discussed for similar errors, such as with node-xmpp-server and with npm. Alternatively, you could try installing the packages using yarn, which is supposed to be completely compatible with npm though I have not tried this with your test files.

@malept
Copy link
Member

malept commented Mar 11, 2017

If you want to try using yarn instead, there's some instructions here (it involves editing the Electron Packager code): #614 (comment)

@malept
Copy link
Member

malept commented May 29, 2017

Since the original issue reporter has not responded to the request for additional information about whether yarn works in over two months, I'm going to assume that they either found the answer in another manner or decided not to pursue this issue. If I'm incorrect, they can respond with answers to the questions posed, and I'll reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 build-host:windows Running Electron Packager on Windows needs info Issue reporter needs to provide more information for maintainers to take action
Projects
None yet
Development

No branches or pull requests

3 participants