WSL icon indicating copy to clipboard operation
WSL copied to clipboard

Unable to install `acorn` npm package (inability to symlink on mounted drives)

Open EvHaus opened this issue 10 years ago • 52 comments

Steps to reproduce:

  • Launch "Bash on Ubuntu on Windows" (note that it appears to use the 'root' user by default)
  • Install nodejs via: curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
  • sudo apt-get install -y nodejs
  • Try to install the acorn package via npm install acorn

You'll get this message:

npm ERR! Linux 3.4.0+
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "acorn"
npm ERR! node v5.10.1
npm ERR! npm  v3.8.3
npm ERR! path ../acorn/bin/acorn
npm ERR! code EPERM
npm ERR! errno -1
npm ERR! syscall symlink

npm ERR! Error: EPERM: operation not permitted, symlink '../acorn/bin/acorn' -> '/mnt/r/path/node_modules/.bin/acorn'
npm ERR!     at Error (native)
npm ERR!  { [Error: EPERM: operation not permitted, symlink '../acorn/bin/acorn' -> '/mnt/r/path/node_modules/.bin/acorn']
npm ERR!   errno: -1,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'symlink',
npm ERR!   path: '../acorn/bin/acorn',
npm ERR!   dest: '/mnt/r/path/node_modules/.bin/acorn',
npm ERR!   parent: 'myproject' }
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!     /mnt/r/path/npm-debug.log

Not sure how to proceed as I'm already root with full permissions

UPDATE: For other nodejs developers finding this issue. Here is what I seem to have uncovered so far:

  • npm install -g {anything} doesn't seem to work
  • npm install {anything} doesn't seem to work if installing anywhere on /
  • npm install {some_packages} on /mnt/{something} sometimes doesn't work depending on whether or not that package needs to create symlinks

EvHaus avatar Apr 07 '16 01:04 EvHaus

Did you run the bash window as administrator in Windows? My very limited understanding is that in order for you to actually have elevated permissions to the underlying file system (and probably other stuff) you need to open the window elevated.

mizzle-mo avatar Apr 07 '16 01:04 mizzle-mo

Launching "Bash on Ubuntu on Windows" with "Run as administrator" did not help resolve this issue. The same error appears.

EvHaus avatar Apr 07 '16 02:04 EvHaus

It appears, ln -s doesn't work on the mounted drives, which is what's causing the issue:

cd /mnt/c/Windows/Temp
touch a
ln -s a b
> ln: failed to create symbolic link ‘b’: Operation not permitted

EvHaus avatar Apr 07 '16 02:04 EvHaus

Before going into possible solutions, I should point out that there are some issues with npm not related to symlinks. I have not tried acorn but will make certain this is one of our test.

I should also point out that we have added a little bit about the filesystem here: https://msdn.microsoft.com/en-us/commandline/wsl/faq.

That said, are you able to install acorn someplace under '/'?

russalex avatar Apr 07 '16 02:04 russalex

That said, are you able to install acorn someplace under '/'?

No. This works:

cd /tmp
touch a
ln -s a b

But this doesn't:

root@localhost:/tmp# npm install acorn
npm WARN enoent ENOENT: no such file or directory, open '/tmp/package.json'
npm WARN tmp No description
npm WARN tmp No repository field.
npm WARN tmp No README data
npm WARN tmp No license field.
npm ERR! Linux 3.4.0+
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "acorn"
npm ERR! node v5.10.1
npm ERR! npm  v3.8.3
npm ERR! path /tmp/node_modules/.staging/acorn-baee3507
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall rename

npm ERR! Error: EACCES: permission denied, rename '/tmp/node_modules/.staging/acorn-baee3507' -> '/tmp/node_modules/acorn'
npm ERR!     at destStatted (/usr/lib/node_modules/npm/lib/install/action/finalize.js:25:7)
npm ERR!     at FSReqWrap.oncomplete (fs.js:82:15)
npm ERR!
npm ERR! Error: EACCES: permission denied, rename '/tmp/node_modules/.staging/acorn-baee3507' -> '/tmp/node_modules/acorn'
npm ERR!     at Error (native)
npm ERR!  [Error: EACCES: permission denied, rename '/tmp/node_modules/.staging/acorn-baee3507' -> '/tmp/node_modules/acorn']
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!     /tmp/npm-debug.log

EDIT: But I'm actually unable to install anything in /. All npm packages seem to give that same error message. Tried in /tmp as well as /home.

Furthermore, trying to install a package globally returns an entirely new error:

root@localhost:/home# npm install -g acorn
Error: could not get uid/gid
net.js:135
    this._handle.open(options.fd);
                 ^

Error: EINVAL: invalid argument, uv_pipe_open
    at Error (native)
    at new Socket (net.js:135:18)
    at createWritableStdioStream (internal/process/stdio.js:142:16)
    at process.stdout (internal/process/stdio.js:10:14)
    at console.js:99:37
    at NativeModule.compile (node.js:395:5)
    at Function.NativeModule.require (node.js:340:18)
    at node.js:223:27
    at Object.<anonymous> (/usr/lib/node_modules/npm/node_modules/uid-number/get-uid-gid.js:16:1)
    at Module._compile (module.js:413:34)

    at /usr/lib/node_modules/npm/node_modules/uid-number/uid-number.js:37:16
    at ChildProcess.exithandler (child_process.js:209:5)
    at emitTwo (events.js:100:13)
    at ChildProcess.emit (events.js:185:7)
    at maybeClose (internal/child_process.js:850:16)
    at Socket.<anonymous> (internal/child_process.js:323:11)
    at emitOne (events.js:90:13)
    at Socket.emit (events.js:182:7)
    at Pipe._onclose (net.js:475:12)

Sorry for all the error messages, just trying to post as much information for you guys as possible.

EvHaus avatar Apr 07 '16 02:04 EvHaus

Actually, love the info. Thanks!

I'll take this up to the devs tomorrow. The fact that you're seeing the socket error makes me think that we have a bug someplace in our code. I'll make certain it gets to the right place.

russalex avatar Apr 07 '16 02:04 russalex

Related to #6 and/or #9 ?

jokeyrhyme avatar Apr 07 '16 05:04 jokeyrhyme

@russalex This could be an issue with running the command as root. I was getting the same stack and the same "could not get uid/gid" running:

npm install npm -g 

I found these switches --user and --unsafe-perm

unsafe-perm
  • Default: false if running as root, true otherwise
  • Type: Boolean

Set to true to suppress the UID/GID switching when running package scripts. If set explicitly to false, then installing as a non-root user will fail.

user
  • Default: "nobody"
  • Type: String or Number

The UID to set to when running package scripts as root.

When I executed:

npm --user root --unsafe-perm true install npm -g

It gets all the way to the end and fails.

I tried again with a few different accounts existing and non-existing. It always makes it to the end and fails with this:

root@localhost:~# npm --user sync --unsafe-perm true install npm -g
- [email protected] node_modules/npm/node_modules/async-some
npm ERR! Linux 3.4.0+
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "--user" "sync" "--unsafe-perm" "true" "install" "npm" "-g"
npm ERR! node v5.10.1
npm ERR! npm  v3.8.3
npm ERR! path /usr/lib/node_modules/npm
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall rename

npm ERR! Error: EACCES: permission denied, rename '/usr/lib/node_modules/npm' -> '/usr/lib/node_modules/.npm.DELETE'
npm ERR!     at moveAway (/usr/lib/node_modules/npm/lib/install/action/finalize.js:38:5)
npm ERR!     at destStatted (/usr/lib/node_modules/npm/lib/install/action/finalize.js:27:7)
npm ERR!     at FSReqWrap.oncomplete (fs.js:82:15)
npm ERR!
npm ERR! Error: EACCES: permission denied, rename '/usr/lib/node_modules/npm' -> '/usr/lib/node_modules/.npm.DELETE'
npm ERR!     at Error (native)
npm ERR!  [Error: EACCES: permission denied, rename '/usr/lib/node_modules/npm' -> '/usr/lib/node_modules/.npm.DELETE']
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!     /root/npm-debug.log

I've got to call it a night, but I will try to look into it more tomorrow. Hopefully someone will have a workaround by then.

mizzle-mo avatar Apr 07 '16 06:04 mizzle-mo

Ok, good news and bad news.

First the good news. Running through the steps on /tmp on one of our dev branches. Looks like there's a fix inbound. This morning I was able to:

/tmp$ npm install acorn /tmp └── [email protected]

npm WARN enoent ENOENT: no such file or directory, open '/tmp/package.json' npm WARN tmp No description npm WARN tmp No repository field. npm WARN tmp No README data npm WARN tmp No license field.

Bad news is that this does not work through /mnt/c. I'll need to write a bug on that one.

The team is hard at work fixing bugs. Every build we put out should have visible improvements. Not certain when this one will hit the insider flight, but it is inbound.

russalex avatar Apr 07 '16 17:04 russalex

@russalex Thanks for the update! When files are written to / where do they actually go? Somewhere on the C: partition? Will files written to / disappear if Bash on Windows is uninstalled?

EvHaus avatar Apr 07 '16 20:04 EvHaus

#14

I believe these are related.

jgchristopher avatar Apr 08 '16 22:04 jgchristopher

@Buck-Rawgers I got the same issue even --user root is used and run my bash as Administrator. Any ideas?

npm ERR! Linux 3.4.0+
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "--user" "sync" "--unsafe-perm" "true" "install" "npm" "-g"
npm ERR! node v5.10.1
npm ERR! npm  v3.8.3
npm ERR! path /usr/lib/node_modules/npm
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall rename

npm ERR! Error: EACCES: permission denied, rename '/usr/lib/node_modules/npm' -> '/usr/lib/node_modules/.npm.DELETE'
npm ERR!     at moveAway (/usr/lib/node_modules/npm/lib/install/action/finalize.js:38:5)
npm ERR!     at destStatted (/usr/lib/node_modules/npm/lib/install/action/finalize.js:27:7)
npm ERR!     at FSReqWrap.oncomplete (fs.js:82:15)
npm ERR!
npm ERR! Error: EACCES: permission denied, rename '/usr/lib/node_modules/npm' -> '/usr/lib/node_modules/.npm.DELETE'
npm ERR!     at Error (native)
npm ERR!  [Error: EACCES: permission denied, rename '/usr/lib/node_modules/npm' -> '/usr/lib/node_modules/.npm.DELETE']
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!     /root/npm-debug.log

mickeyinfoshan avatar Apr 11 '16 05:04 mickeyinfoshan

@Buck-Rawgers until a update comes out fixing symlinks, there isn't much to do at this point.

jgchristopher avatar Apr 11 '16 15:04 jgchristopher

@EvNaverniouk go to %LOCALAPPDATA%\lxss\root and you will find the files that you are looking for (if I understood the first part of your most recent question).

trevren11 avatar Apr 11 '16 16:04 trevren11

any solution available ?

592da avatar Apr 17 '16 10:04 592da

@592da Apparently the Microsoft team has been making some progress here. We're waiting for a new update to Bash on Windows to give it another try. But so far it sounds like if you want to use npm you will need to do it on files in / and NOT on your mounted /mnt/* drives. Which is a bit of a bummer but still better than nothing. We have to wait and see what the team can do.

EvHaus avatar Apr 17 '16 19:04 EvHaus

New build is out :http://aka.ms/wip14328 Release notes for Bash on Ubuntu on Windows are here: https://msdn.microsoft.com/en-us/commandline/wsl/release_notes

I can confirm that npm working (without -g) on / is in the build. Getting these links on /mnt/ is working internally and will soon get onto the release pipeline. No ETA on when it will hit the public.

Keeping this one open until full solution hits the public.

russalex avatar Apr 22 '16 20:04 russalex

@russalex Did some testing on Build 14328 and can confirm your notes

  • :white_check_mark: npm install acorn (and many other packages I tried) works in /tmp
  • :cry: npm install -g acorn still doesn't work (same uv_pipe_open error)
  • :cry: npm install acorn still doesn't work in /mnt/* (same symlink operation not permitted error)

Amazing work so far! And incredible community outreach from the Microsoft team working on this project. Really excited to try out the next public release.

EvHaus avatar Apr 23 '16 04:04 EvHaus

Still having an symlink error on /mnt on build 14328

askbeka avatar Apr 23 '16 14:04 askbeka

does not work for

npm install -g tldr

honwhy avatar Apr 23 '16 15:04 honwhy