Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Error: could not get uid/gid #3

Closed
Laurian opened this issue Feb 19, 2014 · 64 comments
Closed

Error: could not get uid/gid #3

Laurian opened this issue Feb 19, 2014 · 64 comments

Comments

@Laurian
Copy link

Laurian commented Feb 19, 2014

This error was initially reported here: npm/npm#4719

I compiled and installed node 0.10.26 on Ubuntu 12.04; npm update dies:

root@dev:/opt/node-v0.10.26# npm update -g
npm ERR! Error: could not get uid/gid
npm ERR! [ 'nobody', 0 ]
npm ERR! 
npm ERR!     at /usr/local/lib/node_modules/npm/node_modules/uid-number/uid-number.js:36:24
npm ERR!     at ChildProcess.exithandler (child_process.js:635:7)
npm ERR!     at ChildProcess.EventEmitter.emit (events.js:98:17)
npm ERR!     at maybeClose (child_process.js:743:16)
npm ERR!     at Process.ChildProcess._handle.onexit (child_process.js:810:5)
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR!     <http://github.com/npm/npm/issues>

npm ERR! System Linux 3.2.0-54-virtual
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "update" "-g"
npm ERR! cwd /opt/node-v0.10.26
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /opt/node-v0.10.26/npm-debug.log
npm ERR! not ok code 0

Trying as non root a sudo npm update -g yields the same error, only difference is [ 'nobody', 1000 ] instead of [ 'nobody', 0 ]

The only way I could quickly get around was to comment out the error check (line 36), which I guess is not the proper way to do it.

@IlanFrumer
Copy link

Today I upgraded to node v0.10.26, Installed via node.js ppa

I'm running on linux-mint 13.10 xfce x64.

I get the same error when running as root

sudo npm update -g --verbose

npm info it worked if it ends with ok
npm verb cli [ '/usr/bin/node', '/usr/bin/npm', 'update', '-g', '--verbose' ]
npm info using npm@1.4.3
npm info using node@v0.10.26
npm verb node symlink /usr/bin/node
npm ERR! Error: could not get uid/gid
npm ERR! [ 'nobody', 1000 ]
npm ERR!
npm ERR! at /usr/lib/node_modules/npm/node_modules/uid-number/uid-number.js:36:24
npm ERR! at ChildProcess.exithandler (child_process.js:635:7)
npm ERR! at ChildProcess.EventEmitter.emit (events.js:98:17)
npm ERR! at maybeClose (child_process.js:743:16)
npm ERR! at Process.ChildProcess._handle.onexit (child_process.js:810:5)
npm ERR! If you need help, you may report this entire log,
npm ERR! including the npm and node versions, at:
npm ERR! http://github.com/npm/npm/issues

npm ERR! System Linux 3.11.0-12-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "update" "-g" "--verbose"
npm ERR! cwd /home/ilan
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm verb exit [ 1, true ]
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/ilan/npm-debug.log
npm ERR! not ok code 0

@isaacs
Copy link
Contributor

isaacs commented Feb 20, 2014

Caused by 2d701a8. Reverted, pushing a new npm now. Sorry about this.

@IlanFrumer
Copy link

I wasn't able to upgrade to 0.0.5 becuase sudo npm update -g uid-number ironically throws the same error.

I made a quick temporary fix:

sudo sh -c 'curl https://raw.github.com/isaacs/uid-number/v0.0.5/uid-number.js > /usr/lib/node_modules/npm/node_modules/uid-number/uid-number.js'

Now sudo npm update -g works again!

Thanx

@danmactough
Copy link

@IlanFrumer see also - https://gist.github.com/isaacs/9117286

Via twitter:

npmjs: if you are having trouble with sudo global installs on npm@1.4.3, fix with this script:
https://t.co/s8GKtRspX5
fixed client just pushed.

@IlanFrumer
Copy link

@danmactough Thanx.

@isaacs
Copy link
Contributor

isaacs commented Feb 20, 2014

Updated https://gist.github.com/isaacs/9117286 with annotations about what each line does.

@IlanFrumer Yes, that will work, but it depends on having a specific root dir, and if uid-number ever has incompatible changes, it could break stuff. Better to fetch the exact version (and check the shasum while we're at it) and then move into the exact place that npm was installed.

@kuntau
Copy link

kuntau commented Feb 25, 2014

→ ./fix-global-installs.sh  
+ npm cache add uid-number@0.0.5
++ npm get cache
+ cache=/home/kuntau/.npm
++ npm get root -g
+ root=undefined
+ sudo cp /home/kuntau/.npm/uid-number/0.0.5/package/get-uid-gid.js /home/kuntau/.npm/uid-number/0.0.5/package/uid-number.js undefined/npm/node_modules/uid-number
cp: target ‘undefined/npm/node_modules/uid-number’ is not a directory

Unfortunately the script not working for me.. root=undefined?

@isaacs
Copy link
Contributor

isaacs commented Feb 25, 2014

Ack, it should be npm root, not npm get root. Fixed.

@lesion
Copy link

lesion commented Feb 8, 2017

I'm reopening this 'cause I've the same error (for different reasons).
I'm trying to run node/npm inside a runc container. I've tried compiled node (7.5.0) and two packaged release (6.9.5 and 7.2.1) and all of them exit with a bad segfault when trying to install any package globally with npm install -g <package>

npm output:

Error: could not get uid/gid
[ 'nobody', 0 ]
    at /usr/lib/node_modules/npm/node_modules/uid-number/uid-number.js:37:16

looking at that, I saw an exec_file to ./get-uid-gid.js, that's the results of running it manually:

# node /usr/lib/node_modules/npm/node_modules/uid-number/get-uid-gid.js  nobody 0
[ 'nobody', 0 ]
Segmentation fault

and here last lines of strace:

write(11, "[ 'nobody', 0 ]\n", 16[ 'nobody', 0 ]
)      = 16
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
rt_sigprocmask(SIG_BLOCK, ~[], NULL, 8) = 0
rt_sigaction(SIGRT_2, {0x5572dab598, ~[], SA_RESTORER, 0x5572db2a44}, NULL, 8) = 0
getpid()                                = 16651
gettid()                                = 16651
openat(AT_FDCWD, "/proc/self/task", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 12
fcntl(12, F_SETFD, FD_CLOEXEC)          = 0
kill(16651, SIGRT_2)                    = ? <unavailable>
+++ killed by SIGSEGV +++
Segmentation fault

ps. don't know if this is the right place for this
pps. this is an arm64

@skl
Copy link

skl commented Mar 6, 2017

@lesion Same when running a raspian docker container through qemu-user-static (so emulating an armv7l machine). I worked around this by hard-coding for my target user (root) inside the container:

echo "module.exports = function uidNumber(uid, gid, cb) {cb(null, 0, 0)}" > /usr/lib/node_modules/npm/node_modules/uid-number/uid-number.js

Maybe uid-number package could parse output of id <username> and getent group <groupname> commands to do the lookups instead of JS.

@mathias-luedtke
Copy link

@skl: I have the same use case, npm config set unsafe-perm true worked for me

@vielmetti
Copy link

Same, building Mastodon in Docker, I used the npm config set unsafe-perm true line in the Dockerfile and was able to make it past the issue.

http://github.com/tootsuite/mastodon/issues/802

@raulgomis
Copy link

raulgomis commented Jul 11, 2018

We are still experiencing these errors in node alpine for M5 instances in AWS.

docker container run -it node:8-alpine /bin/sh -c 'npm -g --verbose'

Error: could not get uid/gid
[ 'nobody', 0 ]

    at /usr/local/lib/node_modules/npm/node_modules/uid-number/uid-number.js:37:16
    at ChildProcess.exithandler (child_process.js:282:5)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Socket.stream.socket.on (internal/child_process.js:346:11)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at Pipe._handle.close [as _onclose] (net.js:557:12)
TypeError: Cannot read property 'get' of undefined
    at errorHandler (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:205:18)
    at /usr/local/lib/node_modules/npm/bin/npm-cli.js:83:20
    at cb (/usr/local/lib/node_modules/npm/lib/npm.js:224:22)
    at /usr/local/lib/node_modules/npm/lib/npm.js:262:24
    at /usr/local/lib/node_modules/npm/lib/config/core.js:81:7
    at Array.forEach (<anonymous>)
    at /usr/local/lib/node_modules/npm/lib/config/core.js:80:13
    at f (/usr/local/lib/node_modules/npm/node_modules/once/once.js:25:25)
    at afterExtras (/usr/local/lib/node_modules/npm/lib/config/core.js:178:20)
    at Conf.<anonymous> (/usr/local/lib/node_modules/npm/lib/config/core.js:236:22)
    at /usr/local/lib/node_modules/npm/node_modules/uid-number/uid-number.js:39:14
    at ChildProcess.exithandler (child_process.js:282:5)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Socket.stream.socket.on (internal/child_process.js:346:11)
/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:205
  if (npm.config.get('json')) {
                 ^

TypeError: Cannot read property 'get' of undefined
    at process.errorHandler (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:205:18)
    at emitOne (events.js:116:13)
    at process.emit (events.js:211:7)
    at process._fatalException (bootstrap_node.js:378:26)

@shavo007
Copy link

i got this issue moving from docker image mhart/alpine-node:10.6.0 to mhart/alpine-node:10.7.0

@raulgomis
Copy link

raulgomis commented Jul 24, 2018

@isaacs any comments on this issue? are you guys planning to investigate this issue?

@shavo007 both of your images fail in a EC2 M5 instance. Details here:

docker container run -it mhart/alpine-node:10.6.0 /bin/sh -c 'npm -g --verbose'

Unable to find image 'mhart/alpine-node:10.6.0' locally
10.6.0: Pulling from mhart/alpine-node
ff3a5c916c92: Pull complete 
96bc206ec963: Pull complete 
Digest: sha256:607a6e1e75ca22a5aa090e055a86c35bf59823f5d8c5633613c61166526315df
Status: Downloaded newer image for mhart/alpine-node:10.6.0
Error: could not get uid/gid
[ 'nobody', 0 ]

    at /usr/lib/node_modules/npm/node_modules/uid-number/uid-number.js:37:16
    at ChildProcess.exithandler (child_process.js:298:5)
    at ChildProcess.emit (events.js:182:13)
    at maybeClose (internal/child_process.js:961:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)
TypeError: Cannot read property 'get' of undefined
    at errorHandler (/usr/lib/node_modules/npm/lib/utils/error-handler.js:205:18)
    at /usr/lib/node_modules/npm/bin/npm-cli.js:76:20
    at cb (/usr/lib/node_modules/npm/lib/npm.js:228:22)
    at /usr/lib/node_modules/npm/lib/npm.js:266:24
    at /usr/lib/node_modules/npm/lib/config/core.js:83:7
    at Array.forEach (<anonymous>)
    at /usr/lib/node_modules/npm/lib/config/core.js:82:13
    at f (/usr/lib/node_modules/npm/node_modules/once/once.js:25:25)
    at afterExtras (/usr/lib/node_modules/npm/lib/config/core.js:173:20)
    at Conf.<anonymous> (/usr/lib/node_modules/npm/lib/config/core.js:231:22)
/usr/lib/node_modules/npm/lib/utils/error-handler.js:205
  if (npm.config.get('json')) {
                 ^

TypeError: Cannot read property 'get' of undefined
    at process.errorHandler (/usr/lib/node_modules/npm/lib/utils/error-handler.js:205:18)
    at process.emit (events.js:182:13)
    at process._fatalException (internal/bootstrap/node.js:437:27)

docker container run -it mhart/alpine-node:10.7.0 /bin/sh -c 'npm -g --verbose'

Unable to find image 'mhart/alpine-node:10.7.0' locally
10.7.0: Pulling from mhart/alpine-node
911c6d0c7995: Pull complete 
8409151da7fb: Pull complete 
Digest: sha256:fc5dfe8af093948a8f48b018db5addae767c383c8d3430bcd131e371406bfde5
Status: Downloaded newer image for mhart/alpine-node:10.7.0
Error: could not get uid/gid
[ 'nobody', 0 ]

    at /usr/lib/node_modules/npm/node_modules/uid-number/uid-number.js:37:16
    at ChildProcess.exithandler (child_process.js:298:5)
    at ChildProcess.emit (events.js:182:13)
    at maybeClose (internal/child_process.js:961:16)
    at Socket.stream.socket.on (internal/child_process.js:380:11)
    at Socket.emit (events.js:182:13)
    at Pipe._handle.close (net.js:599:12)
TypeError: Cannot read property 'get' of undefined
    at errorHandler (/usr/lib/node_modules/npm/lib/utils/error-handler.js:205:18)
    at /usr/lib/node_modules/npm/bin/npm-cli.js:76:20
    at cb (/usr/lib/node_modules/npm/lib/npm.js:228:22)
    at /usr/lib/node_modules/npm/lib/npm.js:266:24
    at /usr/lib/node_modules/npm/lib/config/core.js:83:7
    at Array.forEach (<anonymous>)
    at /usr/lib/node_modules/npm/lib/config/core.js:82:13
    at f (/usr/lib/node_modules/npm/node_modules/once/once.js:25:25)
    at afterExtras (/usr/lib/node_modules/npm/lib/config/core.js:173:20)
    at Conf.<anonymous> (/usr/lib/node_modules/npm/lib/config/core.js:231:22)
/usr/lib/node_modules/npm/lib/utils/error-handler.js:205
  if (npm.config.get('json')) {
                 ^

TypeError: Cannot read property 'get' of undefined
    at process.errorHandler (/usr/lib/node_modules/npm/lib/utils/error-handler.js:205:18)
    at process.emit (events.js:182:13)
    at process._fatalException (internal/bootstrap/node.js:472:27)

@shavo007
Copy link

Interesting @raulgomis. I rolled back my version on a build agent and it worked...

rzr added a commit to rzr/generic-sensors-webthings that referenced this issue Jul 24, 2018
Relate-to: npm/uid-number#3
Change-Id: I71786586ab3cb4c7b92e08ff962a1fbec1895a35
Signed-off-by: Philippe Coval <p.coval@samsung.com>
@jhnlsn
Copy link

jhnlsn commented Jul 27, 2018

Watching this issue. have same problem

@nshtg
Copy link

nshtg commented Jul 30, 2018

How can such a high severity bug STILL NOT BE FIXED on LTS??

@pranasziaukas
Copy link

Experiencing this behaviour in an official Docker container node:alpine.

@Gp2mv3
Copy link

Gp2mv3 commented Aug 3, 2018

We also have the issue when building with Gitlab CI. 😕

@GauSim
Copy link

GauSim commented Aug 3, 2018

also have that issue in node:8.10.0-alpine on CI :/

@robbyemmert
Copy link

I've opened a fresh issue to add visibility: #7

@SadPencil
Copy link

Same issue with alpine:latest, on arm64

@gabrie30
Copy link

Also happening with node:8-alpine

@rudimk
Copy link

rudimk commented Jan 10, 2019

Facing this on node:8-alpine. Interestingly enough, it cropped up a few months ago in one particular npm project, and adding RUN npm config set unsafe-perm true to the Dockerfile solved it. It suddenly happened with another project today, so I'm not sure what the real problem is here.

@BlueSeph28
Copy link

BlueSeph28 commented Jan 11, 2019

Confirmed Using node:10.15.0-alpine in the Dockerfile, with an Amazon EC2, there is the UID error.
Adding RUN npm config set unsafe-perm true solved it.

@jmcvetta
Copy link

Notice the word "unsafe" in the workaround under discussion. Gives me the creeps. So I prefer something like this:

RUN npm config set unsafe-perm true \
    && npm install some_package \
    && npm config set unsafe-perm false

That way we allow the unsafe operation where we really need it, then go back to normal sane mode.

@rudimk
Copy link

rudimk commented Jan 12, 2019

Notice the word "unsafe" in the workaround under discussion. Gives me the creeps. So I prefer something like this:

RUN npm config set unsafe-perm true \
    && npm install some_package \
    && npm config set unsafe-perm false

That way we allow the unsafe operation where we really need it, then go back to normal sane mode.

Damn and blast, didn't think of that. Going to push this out right away. Thanks!

@SadPencil
Copy link

After all, npm config set unsafe-perm true is just a workaround.
A solution is needed, not a workaround.

36web added a commit to 36web/docker-hexo that referenced this issue Jan 23, 2019
@levindoneto
Copy link

For me, the workaround worked, but it doesn't seem to be a very reliable solution tbh...

@lukepighetti
Copy link

Same issue on node:10-alpine

@danieldram
Copy link

This issue just happened to me as well on npm install -g nodemon with this image. node:8-alpine

@orende
Copy link

orende commented Feb 26, 2019

Not sure why this issue hasn't been addressed yet after 4 years. Is this just a spare-time hobby project for NPM or something?

@lpil
Copy link

lpil commented Feb 26, 2019

@orende Probably best to reply in this issue #7

@keblodev
Copy link

keblodev commented Apr 3, 2019

not sure how why was it closed and not reopened again after so much time :
faced this today on node:8.4.0-alpine

@thorsten
Copy link

thorsten commented Apr 3, 2019

Same here, ran into this issue with node:10-alpine and node:11-alpine. Got it fixed with the "workaround" above.

msheiny added a commit to freedomofpress/securethenews that referenced this issue May 6, 2019
Started hitting this issue npm/uid-number#3.
Seems to be related to how this different CI system is building the
container. Docs for this option can be found:
https://docs.npmjs.com/misc/config.

I don't see any security risks here since we are docker multi-container
building and yanking out files from the initial node build.
msheiny added a commit to freedomofpress/securethenews that referenced this issue May 15, 2019
Started hitting this issue npm/uid-number#3.
Seems to be related to how this different CI system is building the
container. Docs for this option can be found:
https://docs.npmjs.com/misc/config.

I don't see any security risks here since we are docker multi-container
building and yanking out files from the initial node build.
msheiny added a commit to freedomofpress/securethenews that referenced this issue May 15, 2019
Started hitting this issue npm/uid-number#3.
Seems to be related to how this different CI system is building the
container. Docs for this option can be found:
https://docs.npmjs.com/misc/config.

I don't see any security risks here since we are docker multi-container
building and yanking out files from the initial node build.
Firerouge added a commit to Firerouge/alpine-rtorrentvpn that referenced this issue Jun 9, 2019
donbowman added a commit to donbowman/taiga-container-build that referenced this issue Jul 21, 2019
npm config set unsafe-perm true is called otherwise we get

    Error: could not get uid/gid
    [ 'nobody', 0 ]

    at .../uid-number/uid-number.js:37:16
    ...

error.
@ThomasGHenry
Copy link

Still seeing this.

@neutraali
Copy link

Still seeing this.

Can confirm - Our node:10-alpine docker images for CI have started failing their pipelines with:

Error: could not get uid/gid [ 'nobody', 0 ]
    at /usr/local/lib/node_modules/npm/node_modules/uid-number/uid-number.js:37:16
    at ChildProcess.exithandler (child_process.js:298:5)
    at ChildProcess.emit (events.js:182:13)
    at maybeClose (internal/child_process.js:961:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)
TypeError: Cannot read property 'get' of undefined
    at errorHandler (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:205:18)
    at /usr/local/lib/node_modules/npm/bin/npm-cli.js:76:20
    at cb (/usr/local/lib/node_modules/npm/lib/npm.js:228:22)
    at /usr/local/lib/node_modules/npm/lib/npm.js:266:24
    at /usr/local/lib/node_modules/npm/lib/config/core.js:83:7
    at Array.forEach (<anonymous>)
    at /usr/local/lib/node_modules/npm/lib/config/core.js:82:13
    at f (/usr/local/lib/node_modules/npm/node_modules/once/once.js:25:25)
    at afterExtras (/usr/local/lib/node_modules/npm/lib/config/core.js:173:20)
    at Conf.<anonymous> (/usr/local/lib/node_modules/npm/lib/config/core.js:231:22)

/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:205
  if (npm.config.get('json')) {
                 ^
TypeError: Cannot read property 'get' of undefined
    at process.errorHandler (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:205:18)
    at process.emit (events.js:182:13)
    at process._fatalException (internal/bootstrap/node.js:437:27)

@isaacs
Copy link
Contributor

isaacs commented Aug 30, 2019

This issue is 5 years old.

Unless you haven't updated your systems since 2014, whatever you're seeing, it's not "the same" issue, even if it's similar error message text.

I know it's easier to just post a new comment on an existing thread. But I need you to create a new issue. Please include the version of npm that you are using, any debug log file that was generated, and the command that you're running.

Thanks.

@npm npm locked and limited conversation to collaborators Aug 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests