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

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

Closed
EvHaus opened this issue Apr 7, 2016 · 52 comments
Closed

Comments

@EvHaus
Copy link

EvHaus commented Apr 7, 2016

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
@mike-morr
Copy link

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.

@EvHaus
Copy link
Author

EvHaus commented Apr 7, 2016

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

@EvHaus
Copy link
Author

EvHaus commented Apr 7, 2016

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 EvHaus changed the title Unable to install acorn npm package Unable to install acorn npm package (inability to symlink on mounted drives) Apr 7, 2016
@russalex
Copy link
Contributor

russalex commented Apr 7, 2016

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 '/'?

@EvHaus
Copy link
Author

EvHaus commented Apr 7, 2016

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.

@russalex
Copy link
Contributor

russalex commented Apr 7, 2016

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.

This was referenced Apr 7, 2016
@jokeyrhyme
Copy link

Related to #6 and/or #9 ?

@mike-morr
Copy link

@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.

@russalex
Copy link
Contributor

russalex commented Apr 7, 2016

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.

@EvHaus
Copy link
Author

EvHaus commented Apr 7, 2016

@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?

@jgchristopher
Copy link

#14

I believe these are related.

@mickeyinfoshan
Copy link

@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

@jgchristopher
Copy link

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

@trevren11
Copy link

@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).

@592da
Copy link

592da commented Apr 17, 2016

any solution available ?

@EvHaus
Copy link
Author

EvHaus commented Apr 17, 2016

@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.

@russalex
Copy link
Contributor

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.

@EvHaus
Copy link
Author

EvHaus commented Apr 23, 2016

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

  • npm install acorn (and many other packages I tried) works in /tmp
  • 😢 npm install -g acorn still doesn't work (same uv_pipe_open error)
  • 😢 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.

@askbeka
Copy link

askbeka commented Apr 23, 2016

Still having an symlink error on /mnt on build 14328

@honwhy
Copy link

honwhy commented Apr 23, 2016

does not work for

npm install -g tldr

@pgrm
Copy link

pgrm commented Apr 23, 2016

I've "fixed" npm to install global packages into the home directory via .npmrc

prefix=/home/peter/.npm-packages

Now I'm getting a new error when I try installing any package:

npm install -g yo

npm WARN deprecated [email protected]: this package has been reintegrated into npm and is now out of date with respect to npm
npm ERR! Linux 3.4.0+
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "yo"
npm ERR! node v5.10.1
npm ERR! npm  v3.8.3
npm ERR! code EIO

npm ERR! EIO: i/o error, read
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /home/peter/npm-debug.log

npm --version
3.8.3
node --version
v5.10.1

@kleinesfilmroellchen
Copy link

This is STILL an issue in 2022. Debian 12, 4.19.128-microsoft-standard #1 SMP Tue Jun 23 12:58:10 UTC 2020 x86_64 GNU/Linux, nodejs v16.15.1, npm 8.13.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests