ied icon indicating copy to clipboard operation
ied copied to clipboard

EPERM on Windows 10

Open victorwpbastos opened this issue 9 years ago • 16 comments

Install is not working on Windows 10 64:

image

victorwpbastos avatar Nov 20 '15 16:11 victorwpbastos

Disclaimer: I don't have access to a Windows machine. Although ied should work on Windows, it hasn't been tested on it.

ied heavily relies on symlinks. It looks like you don't have the correct permissions to create those.

alexanderGugel avatar Nov 21 '15 03:11 alexanderGugel

Windows requires Admin privileges to create symlinks. Silly but that's the way it is.

mgol avatar Nov 22 '15 23:11 mgol

That may be the reason for the elevated env requirement: https://en.wikipedia.org/wiki/Symlink_race.

If you didn't know about it already, you can quite easily run programs in the elevated mode by selecting "Run as administrator" from the context menu.

fatfisz avatar Nov 23 '15 12:11 fatfisz

Uhhhh... that sucks. Any hack around this? If not, we should at least warn the user why it didn't work...

alexanderGugel avatar Nov 23 '15 19:11 alexanderGugel

I think I've found quite a painless solution - powershell.

const ps = require('node-powershell');

ps('Start-Process -Verb runAs cmd "/C","mklink /D D:\link D:\source"');

There was a prompt asking for permission and afterwards a link was created.

fatfisz avatar Nov 23 '15 21:11 fatfisz

I've been experimenting with this on Windows and came to a conclusion: this can't be done in a symlink by symlink fashion.

The problem is, powershell has to be launched in order to launch cmd in the elevated mode (which prompts the user). Each time cmd is launched, there is a prompt. That means a lot of prompts for one install. This is caused by powershell being unable to launch cmd "in the same window" (so that we'd be able to issue the mklink command directly) and with the "runas" verb (which gives us the elevated mode).

So I suggest doing one of these:

  • warn Windows users when elevated mode is not detected
  • create a little bootstrapping script, which will detect if the program is running in an elevated mode, and if not, then launch ied with all arguments through powershell in the elevated mode (and then exit) - this will add an overhead of a couple of ms + MBs needed for a new process, but it should be small compared to the main program

fatfisz avatar Nov 30 '15 09:11 fatfisz

+1 on this issue.... I'm getting it too.

morales2k avatar Jan 27 '16 19:01 morales2k

@mgol, perhaps this is somehow a separate issue, but the issue persists for me even running as administrator. It bugs out a lot further down in the process than if I was running it as a regular user, but I'm still unable to complete the installation.

image

AMorporkian avatar Mar 10 '16 18:03 AMorporkian

I also get an issue further down the track when running as administrator:

λ ied install
[==============================] 100.00%C:\Users\jschreuder\AppData\Roaming\npm\node_modules\ied\bin\cmd.js:57
          throw err
          ^

Error: EPERM: operation not permitted, rename 'C:\Projects\MyProj\node_modules\.tmp\7e13da55-f351-455e-9384-d1886cb2351c' -> 'C:\Projects\MyProj\node_modules\3cd42b2bbd6f6c52977ffaedc5d9c3362057e232'
    at Error (native)

JoshSchreuder avatar Mar 14 '16 23:03 JoshSchreuder

@alexanderGugel I think I can get around the permission issue using junctions on Windows. Basically just passing the type 'junction' into forceSymlink() seems to remove the need for an Admin command prompt.

After my changes, ied runs successfully (although I still get the rename error I noted above intermittently - will investigate), and I get a node_modules folder filled with packages :smile:)

Are you interested in me putting up a PR with this change? At the moment I've just hardcoded it into expose.js, install.js and link.js, like this for example:

var type = process.platform !== 'win32' ? 'file' : 'junction'
//...
forceSymlink(srcPath, dstPath, type, cb)

But I'm happy to move the platform check into one place if you could give me some pointers (Node stuff isn't my forte, sorry)

JoshSchreuder avatar Mar 15 '16 02:03 JoshSchreuder

@JoshSchreuder There is an 'isWindows' check in config.js you could probably use.

AMorporkian avatar Mar 16 '16 15:03 AMorporkian

@JoshSchreuder There is an 'isWindows' check in config.js you could probably use.

Thanks, I've put up a PR which uses the check (#95).

JoshSchreuder avatar Mar 16 '16 23:03 JoshSchreuder

although I still get the rename error I noted above intermittently - will investigate

Did a bit of digging into this and it's potentially an antivirus thing (ughhhhhh), npm have 'solved' it like so: https://github.com/npm/npm/commit/beeb7fd82e3cc543a9911fe87ec096f8eed29e7a

JoshSchreuder avatar Mar 17 '16 04:03 JoshSchreuder

Ah that explains why ied didn't work for me on Windows. I'll try as administrator.

FYI, I ran into a similar problem with one of my modules recently, and my approach was to make "pointer" modules that look something like this:

package.json:

{
    "name": "{{modulename}}",
    "private": true,
    "version": "{{moduleversion}}"
}

index.js:

module.exports = require(__dirname + '/' + '{{relative/path/to/actual/module}}')

Obviously it's not as general as proper symlink because it only works for modules, but I thought I'd mention it just in case.

billiegoose avatar Mar 22 '16 15:03 billiegoose

@JoshSchreuder, I run into the rename thing occasionally and I'm definitely not running any antivirus software, or anything of that sort. I'll take some time today and try to dig into it more. It happens fairly consistently on the same folders too, which is interesting.

AMorporkian avatar Mar 22 '16 16:03 AMorporkian

You guys get symlink problems, I get rename issues :frowning:

[==============================] 100.00%C:\Users\<xxxx>\Roaming\npm\node_modules\ied\bin\cmd.js:57
          throw err
          ^

Error: EPERM: operation not permitted, rename 'D:\Projects\<xxxx>\node_modules\.tmp\c1510493-3b61-4eaf-b5a7-743438e26d4a' -> 'D:\Projects<xxxx>\node_modules\f7b6cee64aabea6944b2a679023d533e40aebfdc'
    at Error (native)

nazwa avatar Apr 04 '16 16:04 nazwa