Skip to content

os.userInfo throws if no username in docker container #25714

Description

@raido

Original issue opened here: sindresorhus/username#21

It turns out that running a script with docker run with --user flag set, then user actually has no $HOME or username. This in turn causes following error: uv_os_get_passwd returned ENOENT (no such file or directory) if os.userInfo() is accessed.

Some people have resorted to try catch blocks:

https://github.com/moleculerjs/moleculer/pull/396/files#diff-38423b3db1f1c2a43666c7ad898ba126R45

But is is not documented that os.userInfo() ever throws - https://nodejs.org/dist/latest-v10.x/docs/api/os.html#os_os_userinfo_options

  • Version: v8, v10
  • Platform: Linux, Docker container

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to Node.js documentation.osIssues and PRs related to the os subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions