Serverless-python-requirements: "process.getuid is not a function" on Windows

Created on 19 Apr 2017  路  13Comments  路  Source: UnitedIncome/serverless-python-requirements

process.getuid is not a function error when running on Windows. This seems to be a POSIX only function.

Are you able to conditionally exclude it?

All 13 comments

Does -u on docker similarly not exist then? Or rather, how does windows + docker deal with user issues?

I haven't yet played with docker. I'll ask around.

Come to think of it, could you create the docker command only when the project specifies it'll be dockerizing the packages? As I'm not using docker, this will become a non-issue for me.

Good call. I didn't realize I was creating the command for docker even if it isn't being used. Should be an easy fix, I'll do it when I get the chance.

@ChrisAnn, you should be able to use v2.1.2 that I just pushed. I'll leave this issue open tho to track the fact that the dockerize option doesn't work on windows.

I tried 2.1.2 and 2.3.3 and I get the error on Windows.

@FelschR are you trying to use docker? If so, do you know the answer to my above question about a -u flag?

@dschep Yes, I was. I'll check it next week.

The help for docker run lists:

  -u, --user string                    Username or UID (format:
                                       <name|uid>[:<group|gid>])
      --userns string                  User namespace to use
      --uts string                     UTS namespace to use

I ran the following command in the CMD to see what happens:
docker run -u process.getuid() lambci/lambda:build-python2.7
And I got the following error:

At line:1 char:30
+ docker run -u process.getgid()
+                              ~
An expression was expected after '('.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : ExpectedExpression

Now when I put process.getuid() in quotes like this:
docker run -u "process.getuid()" lambci/lambda:build-python2.7
it seems to work fine:

Unable to find image 'lambci/lambda:build-python2.7' locally
build-python2.7: Pulling from lambci/lambda
d70ace93110d: Pull complete
30488ed80050: Pull complete
a1689653829f: Pull complete
Digest: sha256:9bd1b82b73a2317c1ce491f80aaa28443ab6b05381434193f33c99eb0df700b5
Status: Downloaded newer image for lambci/lambda:build-python2.7
docker: Error response from daemon: No command specified.
See 'docker run --help'.

Maybe that's the problem? I have no clue where process.getuid() comes from.
I hope this helps you a bit.

Oh, I stumbled upon the node.js documentation for process.getuid() and it actually states that it's only available on POSIX platforms;
https://nodejs.org/api/process.html#process_process_getuid

Cool Thanks. Yeah i knew the nodeJs side of the story, was unsure of the docker side. That looks like maybe on window It could fall back to process.env.USERNAME. Could you try the branch I just pushed relating to this? npm install unitedincome/serverless-python-requirements#docker-windows

@dschep I tried it and this is the result:

  docker: Error response from daemon: linux spec user: unable to find user felix_schroeter: no matching entries in passwd file.


     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

Ah, that makes sense that the user wouldn't exist in the linux VM that docker for windows creates. I guess i'll just completely skip the -u option on windows, barring a better option. I'll whip that up when I have some downtime again.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bsamuel-ui picture bsamuel-ui  路  3Comments

amitm02 picture amitm02  路  6Comments

calclavia picture calclavia  路  5Comments

xedef picture xedef  路  3Comments

davegravy picture davegravy  路  5Comments