-
Notifications
You must be signed in to change notification settings - Fork 436
npm install fails on Windows with "EPERM, operation not permitted" error during rename #19
Comments
I won't have access to a windows machine until after the holidays, will be happy to review patches though. |
This node issue (fixed) looks very related: nodejs/node-v0.x-archive#3051 Will try to understand what's causing this. |
I've fiddled around with the project's install script. Something "strange" happens during the extract->rename process -- if renaming is done immediately or soon after extracting - the error shows its ugly head. I.e. even if I call finishIt() 10-20-30 secs after extracting -- renaming still fails. However, if a bit more time passes (e.g. 60 secs) - renaming succeeds. Looks like the file descriptors of the extracted files are not being released so renaming fails until they are (by a timeout?). Not sure yet if this is a problem of unzip or the underlying fstream library. |
I have the same issue on my Windows 7 x64 machine. |
Is this still a problem with Node 0.8.19? |
Yes. unfortunately the same error. |
My windows machine died and I'm not replacing it. If someone wishes to debug and patch that'd be awesome. |
I gave it another shot, but didn't get much further than the last time. Here's what I "have": if finishIt() doesn't run immediately after extraction (this is the function doing the renaming), but with a 10sec delay - it is possible that the error will not show up. Why "possible"? Because sometimes it does, and sometimes it doesn't. The longer the delay in executing finishIt(), the higher the probability that the error will not show up. If I try manually deleting the extracted folder immediately after extraction (through windows explorer) - the error manifests as the "You need permission to perform this action. You require permission from Administrators to make changes to this folder." This is strange since my user account is indeed in the Administrators group. And if I keep trying to delete the file, after some time it just succeeds. So, this suggests that it really is an fs ownership issue, but not sure where to go from here. The strangest thing is the nondeterminism in the appearance of the error -- as if there is some randomness as to when the ownership of the folder magically resolves itself. At first I thought that the finishiIt() function was getting called before all extracted files were closed by fstream, but after carefully logging everything - I found that this was not the case and finishIt() is called after all extracted files are closed by fstream. Anyone know how to track low-level fs events that might indicate what changes in the permissions of the extracted files and when? |
I was also experiencing this issue, I do believe the culprit is the unzip library and it's streams, but I haven't been able to confirm that yet. Though I was able to confirm that switching from unzip to adm-zip fixed the issue on my system. So I've submitted pull request #27. I'd appreciate it if any of you could test my code and verify that the change fixes the issue for you (and doesn't cause any others). |
Hey Steve! Hate to say this but -- I have the same OS, npm and node version as you do, but using your fix with adm-zip does not fix the problem on my machine. I get the same exact error. :( However (!), this made me rethink if this even is an issue with node.js -- and I believe I've found the source of the problem. It's our beloved anti-virus software. Yes. You know it and you're sighing and shaking your head just as I have :). What's worse is that someone else reported a similar issue for npm here: https://github.com/isaacs/npm/issues/2288 and pointed to a fix here: Anyway, on windows machines, we just need to re-try renaming until the EPERM error stops showing up, which happens after the AV software stops scanning the new files. Needless to say - I've applied a similar fix to the project (the one which uses unzip) and now everything works fine (I've tried it a dozen times). 🍰 Pull request with the patch incoming shorty. |
Oh my god. That is it after all. I disabled my anti-virus software (NOD32 in my case) and retried the original code. It installed flawlessly on the first go. That is just, wow. Alright, well at least you figured it out before I wasted a bunch of people's time. I'll withdraw my pull request, looking forward to seeing yours go out soon! |
@stevenbenner I would have not thought of the A/V stuff without you trying the adm-zip fix. So, hats off to you too, sir :) |
I can confirm that the error vanishes after disabling A/V software. (Panda Cloud here) |
Nice catch. Just hit this issue as well and this thread saved me some serious time. Cheers! |
Try running |
Thank you FredyC!!! 🎯 |
I had this problem today with Windows Server 2012R2, npm v1.3.24, and node v0.10.25. In my case, it was a slightly different backtrace starting with an
Then it worked ok, so probably a quirk of windows permissions, or something is walking up the filesystem folder hierarchy looking for a config file. |
I ran in to the same problem. Dev system:
Command: $ npm install Local project with package.json and npm-shrinkwrap.json where phantomjs is a dependency of grunt-html-snapshot@0.6.1 (html-snapshots => same prob). Actually I did not ran into this problem, but my co-worker did who has an exact setup to mine. Turning off AVG, windows defender or windows firewall has no effect. These are the exact steps I did on my co-workers system:
My opinion: Seems that when you never ran the node.js command prompt, the system seems to think that it is unsafe for cmd or GitBash to run an exe (phantomjs.exe) through node.js. Hope this helps someone out. |
@BohemMedia WTF I just did what you said running the node cmd prompt only once and now all my 99 problems are gone. Crazy. So I can confirm this works for me. (Win 7 x64 node 0.12.0) |
i just ran into the same problem on win 7 x64 and what shoudl i say: turnig off commodo antivirus while installing fixed the issue, thanks a lot! |
@izuzak wow!! It works after disable AV software, you really save our times, thanks vvvvvvvvvvery much! :-) |
Wow, I had the same issue. Simply running NodeJs command prompt as administrator fixed it. I didn't need to execute any command from Node.js cmd prompt, I've only launched it, exactly as @BohemMedia said. Thanks! |
I had the same issue even using command prompt as administrator the problem happened. After stopping Panda AntiVirus the problem was solved |
What if you cannot disable antivirus because its running as a service on a network? |
@mokanfar per the faq, you can put phantomjs on PATH manually: |
@BohemMedia is correct. run npm command prompt once. then you can use npm from the git bash without issues. |
On windows |
installing npm globally as admin, and then running npm cache clean fixed my problem. Thanks guys! |
Hi, please, could anyone explain to me how to install hospitalrun? I am a physician from Venezuela and I do need this software for my patients. I have no idea how to program. This is my e-mail, falasarabeatle@hotmail.com. thanks |
+1 for suspending antivirus (Kapersky Internet Security 2016) in my case. Possibly adding an exception should work too |
I'd like to report that after clearing the npm cache, using --force, running in the node.js command prompt, AND disabling Windows Defender (my only anti-virus), I am still encountering this error. per npm/npm#9696 , this may be an NPM bug exacerbated by slow windows machines. |
There is a fix for this on github! To fix the problem, I followed the suggestion at: Specifically:
function unpack_ ( tarball, unpackTarget, dMode, fMode, uid, gid, cb ) { function moveIntoPlace (folder, unpackTarget, cb) { |
close all other software may open this directory or sub-directory here |
Running nodejs command prompt as administrator worked perfectly! Thank you! |
Doing a
npm install phantomjs
on a Win7 machine is giving me the error below. Looks like everything works up until the very end, when the install script breaks on renaming the phantomjs dir?I'm running the command under an admin account and I've also tried the "windows key -> type cmd -> right click on cmd icon and Run as administrator" trick but get the same error. I also checked that I have the required privileges on the directories.
Never had problems with installing any npm package before on the same machine.
Any ideas? The
ENOTEMPTY
error code suggests that the underlying cause is renaming an non-empty dir? 😕Thanks!
The text was updated successfully, but these errors were encountered: