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

Call to os.userInfo can lead to uncaught SystemError #4438

Open
jurgenf opened this issue May 13, 2020 · 3 comments
Open

Call to os.userInfo can lead to uncaught SystemError #4438

jurgenf opened this issue May 13, 2020 · 3 comments
Labels

Comments

@jurgenf
Copy link

jurgenf commented May 13, 2020

Description:
Somewhere during releases the following code has been introduced in a release:
53d0afa#diff-7c6997f05d0c3a730c4dd717afb61024
The problem I encounter is that in some cases the call to os.userInfo(); can lead to a SystemError if the username or homedirectory is not returned by the OS as described here: https://nodejs.org/api/os.html#os_os_userinfo_options For me this is the case when running the ionic-cli in a Docker container using the --user parameter to specify a custom UID.

Steps to Reproduce:
Run the command npx ionic build --prod --verbose inside a docker container using the --user Docker argument to specify a specific UID.

Output:

ionic:utils-terminal Environment variables for CI detected: BUILD_ID, BUILD_NUMBER
SystemError [ERR_SYSTEM_ERROR]: A system error occurred: uv_os_get_passwd returned ENOENT (no such file or directory)

My ionic info:
Command can not run due to the aforementioned error. This was tested with the @ionic/cli latest package and is reproducible from latest until version 5.4.7 where the code was introduced. Also the exception is thrown by all modern Node versions.

Possible solution:
As the method contains multiple methods of detecting a usable shell. It might be proficient to simply catch the exception and carry on using one of the following detection methods to determine the shell.

@mgiova
Copy link

mgiova commented Mar 10, 2023

I'm surprised this is still a problem after all this time. I encountered the problem while trying to build a capacitor app using TeamCity.

This is the stack trace documenting the exact problem

node:os:355
    throw new ERR_SYSTEM_ERROR(ctx);
    ^

SystemError [ERR_SYSTEM_ERROR]: A system error occurred: uv_os_get_passwd returned ENOENT (no such file or directory)
    at new SystemError (node:internal/errors:244:5)
    at new NodeError (node:internal/errors:355:7)
    at Object.userInfo (node:os:355:11)
    at getShell (/Users/user212060/TeamCityAgent/work/b23c190b6167b5c7/node_modules/@ionic/utils-terminal/dist/info.js:15:26)
    at Object.<anonymous> (/Users/user212060/TeamCityAgent/work/b23c190b6167b5c7/node_modules/@ionic/utils-terminal/dist/info.js:35:12)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at Module.require (node:internal/modules/cjs/loader:1061:19) {
  code: 'ERR_SYSTEM_ERROR',
  info: {
    errno: -2,
    code: 'ENOENT',
    message: 'no such file or directory',
    syscall: 'uv_os_get_passwd'
  },
  errno: [Getter/Setter],
  syscall: [Getter/Setter]
}

Node.js v18.12.1

And this is the PR the avoids it allowing the build to be completed successfully: #4958

@amish1188
Copy link

Well i found a way to make it work in my build after hours of testing different solutions. I just set up an env variable SHELL = {}. Not sure if it's the best solution but it works.

@leonnelleijing
Copy link

Well i found a way to make it work in my build after hours of testing different solutions. I just set up an env variable SHELL = {}. Not sure if it's the best solution but it works.

But it seems this will still got the error, since it will always call os. userinfo?

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

No branches or pull requests

5 participants