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

[BUG] npm install in a workspaces environment requires admin permissions on Windows #1923

Closed
RoystonS opened this issue Oct 7, 2020 · 6 comments
Assignees
Labels
Bug thing that needs fixing platform:windows is Windows-specific Release 7.x work is associated with a specific npm 7 release

Comments

@RoystonS
Copy link

RoystonS commented Oct 7, 2020

Current Behavior:

npm install in a workspaces environment fails if the current user is not running under administrator privileges because directory symlinks can't be created on Windows without admin privilege (or some rather non-standard configuration)

Expected Behavior:

npm install would ideally 'just work' on Windows, which could be done by using Windows 'junctions' instead of directory symlinks. These are pretty much the same as directory symlinks but don't require admin permissions.

(This is what yarn does, incidentally. I'd love to be able to move back from yarn to npm, and workspace support is the killer feature for us.)

With the current behaviour, npm 7 workspace support will be broken on Windows unless the user runs as admin or does some non-trivial configuration to enable the creation of directory symlinks. (No, I don't know why Windows requires this hoop-jumping just to make symlinks, but it does. It's grim. But junctions are an easy workaround for it.)

Steps To Reproduce:

  1. Create a simple workspaces environment on Windows
  2. run npm install

See error:

npm ERR! code EPERM
npm ERR! syscall symlink
npm ERR! path ..\..\packages\pkg2
npm ERR! dest C:\Dev\monorepo\node_modules\@my\pkg2
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, symlink '..\..\packages\pkg2' -> 'C:\Dev\monorepo\node_modules\@my\pkg2'npm ERR!  [Error: EPERM: operation not permitted, symlink '..\..\packages\pkg2' -> 'C:\Dev\monorepo\node_modules\@my\pkg2'] {
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'symlink',
npm ERR!   path: '..\\..\\packages\\pkg2',
npm ERR!   dest: 'C:\\Dev\\monorepo\\node_modules\\@my\\pkg2'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

Having to run as administrator isn't a realistic workaround for this sort of scenario; it would cause a lot of extra effort modifying build machines and scripts to be able to switch to administrator mode, and would massively weaken security as a result.

Environment:

OS: Windows 10
Node: 12.18.3
npm: 7.0.0-rc.3

@RoystonS RoystonS added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels Oct 7, 2020
@RoystonS RoystonS changed the title [BUG] npm workspace install requires admin permissions on Windows [BUG] npm install in a workspaces environment requires admin permissions on Windows Oct 7, 2020
@darcyclarke darcyclarke added platform:windows is Windows-specific and removed Needs Triage needs review for next steps labels Oct 8, 2020
@darcyclarke darcyclarke added this to the OSS - Sprint 17 milestone Oct 8, 2020
@salvoravida
Copy link

salvoravida commented Oct 17, 2020

Hi, pr that fix it

npm/arborist#162

@RoystonS
Copy link
Author

Lovely - thank you. Certainly looks like it'll fix it.

(Not sure how that resulting failing build's going to be fixed though. Dealing with a mandated 100% branch coverage for something that needs platform-specific logic is going to be a little 'tricky'...)

@CAM-Gerlach
Copy link

For the record, I can confirm this also occurs . Node 15.0.1, npm 7.0.3 (latest current) but not Node 14.15.0 , npm 6.14.8 (latest LTS) when simply doing a regular install with npm install on packages that specified certain (e.g. test) dependencies as local paths, like igorshubovych/markdownlint-cli .

As discussed in pre-commit/pre-commit#1681 , this makes Node 15/npm 7 unusable for running this popular hook on Windows, unless all developers either work in an admin console, or manually enable symlink support (neither of which isn't really feasible given we get a large number of contributors who are students, scientists, engineers or beginning programmers, and the goal with pre-commit is to greatly reduce the barrier to entry, not increase it).

Therefore, fixing this would be greatly appreciated! I'm a Python developer, not a Node whiz, but I can try to help test if needed. Thanks!

@ljharb
Copy link
Contributor

ljharb commented Nov 3, 2020

What about with npm v7.0.7?

@RoystonS
Copy link
Author

RoystonS commented Nov 3, 2020

@ljharb It's still a problem with v7.0.7. The fix (npm/arborist#162) hasn't been merged in yet.

@CAM-Gerlach
Copy link

Thanks @isaacs @nlf ! Much appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing platform:windows is Windows-specific Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants