EMBER_CLI_PROD_ASSETS を 1 にするとアセットのプリコンパイルがクラッシュする

Comes from New installs will default to Ember CLI builds in Production - #36 by david

Hi Team,

While trying setting EMBER_CLI_PROD_ASSETS to 1, I’m getting the following at the time of precompiling assets (version 2.9.0.beta2 commit: d2de058ff51f204fcf85c86a00750a59505af3bb):

yarn run v1.22.17
$ /var/www/discourse/app/assets/javascripts/node_modules/.bin/ember build -prod
WARNING: Node v16.13.2 is not tested against Ember CLI on your platform. We recommend that you use the most-recent "Active LTS" version of Node.js. See https://git.io/v7S5n for details.
DEPRECATION: The integration of jQuery into Ember has been deprecated and will be removed with Ember 4.0. You can either opt-out of using jQuery, or install the `@ember/jquery` addon to provide the jQuery integration. Please consult the deprecation guide for further details: https://emberjs.com/deprecations/v3.x#toc_jquery-apis
A system error occurred: uv_os_get_passwd returned ENOENT (no such file or directory)

node:internal/errors:464
    ErrorCaptureStackTrace(err);
    ^

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:233:5)
    at new NodeError (node:internal/errors:336:7)
    at Object.userInfo (node:os:347:11)
    at summarizeProcess (/var/www/discourse/app/assets/javascripts/node_modules/console-ui/lib/summarize-process.js:17:15)
    at writeError (/var/www/discourse/app/assets/javascripts/node_modules/console-ui/lib/write-error.js:114:3)
    at UI.writeError (/var/www/discourse/app/assets/javascripts/node_modules/console-ui/lib/index.js:167:20)
    at CLI.logError (/var/www/discourse/app/assets/javascripts/node_modules/ember-cli/lib/cli/cli.js:318:13)
    at CLI.run (/var/www/discourse/app/assets/javascripts/node_modules/ember-cli/lib/cli/cli.js:253:12)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async module.exports (/var/www/discourse/app/assets/javascripts/node_modules/ember-cli/lib/cli/index.js:145:12) {
  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]
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Any hint about why this is happening?

Cheers,
Ismael

「いいね!」 1

これはインストールガイドを使用した本番環境へのインストールですか?

再構築を試していただけますか?

「いいね!」 1

インスタンスを再構築しても成功しません。uv_os_get_passwd の呼び出しが原因で発生しているのか、または一般的にこのエラーの原因は何なのか、システム/設定で特定のユーザーが設定されていることを期待しているのか、といった点について、より詳しく知りたいです。

よろしくお願いいたします。
イスマエル

Discourse イメージは具体的にどのように実行していますか?セキュリティのための追加フラグはありますか?

このトレースに従うと、問題は Ember-CLI のビルドが失敗しており、エラーを印刷しようとしているときに、さらに別の例外が発生して実際の例外が隠蔽されていることです。

Discourse イメージに入って、以下を試していただけますか?

node
const os = require('os');
os.userInfo().shell

「いいね!」 1

興味深いことに、あなたの提案を実行したところ、これが出力されました(root以外のランダムなユーザーで内部ライブラリシステムにアクセスすることを意図している場合は、完全に理にかなっています)。

node
Welcome to Node.js v16.13.2.
Type ".help" for more information.

> const os = require('os');
undefined

> os.userInfo().shell
Uncaught:
SystemError [ERR_SYSTEM_ERROR]: A system error occurred: uv_os_get_passwd returned ENOENT (no such file or directory)
    at __node_internal_captureLargerStackTrace (node:internal/errors:464:5)
    at new SystemError (node:internal/errors:233:5)
    at new NodeError (node:internal/errors:336:7)
    at Object.userInfo (node:os:347:11) {
  code: 'ERR_SYSTEM_ERROR',
  info: {
    errno: -2,
    code: 'ENOENT',
    message: 'no such file or directory',
    syscall: 'uv_os_get_passwd'
  },
  errno: [Getter/Setter: -2],
  syscall: [Getter/Setter: 'uv_os_get_passwd']
}

>

Discourseイメージはどのように実行していますか?セキュリティのために追加のフラグはありますか?

OpenShiftをベースにしたコンテナソリューションを使用しており、DiscourseはランダムなユーザーIDで実行されています。今のところ問題はありません。アプローチは公式のインストールガイドと非常によく似ています。
EMBER_CLI_PROD_ASSETS0 に設定することでこの問題を回避できます。アセットは以前のようにプリコンパイルされますが、遅かれ早かれ、この方向に進む計画がある場合、現在のプリコンパイルプロセスが放棄された場合、このようなソリューションにとって深刻な問題となる可能性があります。

そこで、いくつか質問があります。

  • 以前の方法でのアセットのプリコンパイルを放棄する予定はありますか?(もしそうなら)その時期はいつ頃ですか?
  • os マシンに別の方法でアクセスする方法はありますか、または別の方法を検討していただけますか?これにより、ランダムなユーザーIDを持つコンテナソリューションでも引き続き機能しますか?

この件についてご検討いただき、誠にありがとうございます。

よろしくお願いいたします。
Ismael

「いいね!」 1

今後数週間で EMBER_CLI_PROD_ASSETS を削除します。

直接使用しているわけではありませんが、依存関係の依存関係の依存関係…といった形で使用しています。これも奇妙な呼び出しだと思いますが、あまりコントロールできるものではありません。

「いいね!」 1

表示されているエラーは実際のエラーではありません。
実際のエラーを表示しようとしたときに発生するエラーです…

「いいね!」 3

Issue with non 'username' defined · Issue #2373 · nodejs/node-gyp · GitHub および os.userInfo throws if no username in docker container · Issue #25714 · nodejs/node · GitHub と全く同じ問題です。

ランダムなユーザー ID を使用すると、os のシステム関連ユーティリティメソッドやプロパティをロードする際に node がエラーを発生させます。

確認ですが、古い方法は完全に非推奨/削除されるということでよろしいでしょうか?

よろしくお願いいたします。
Ismael

「いいね!」 1

はい、上記の投稿で理解しました。チームがこれを許可するための特別なアクション/チェックを行わない限り、ランダムなユーザーIDを使用する時代は終わったと思います。

よろしく、
イスマエル

「いいね!」 1

はい、その通りです。EmberJSプロジェクトが推奨するものに追従し、より標準的なものにするために、この新しいアセットパイプラインを数年かけて徐々にリリースしてきました。すでにロールアウトの最終段階に入っています。

「いいね!」 2

承知いたしました。
いつも詳細な情報提供ありがとうございます。大変助かります。

よろしくお願いいたします。
イスマエル

「いいね!」 1

念のため、誰かの役に立つかもしれないので共有します。ランダムなUIDを持つEmber CLIを期待どおりに動作させる少なくとも1つの方法があり、それはrake assets:precompile操作を実行する際に、割り当てられたランダムなUIDに/etc/passwdの下にエントリがあることを保証することです。

たとえば次のようになります。

if [ `id -u` -ge 10000 ]; then
  cat /etc/passwd | sed -e "s/^discourse:/builder:/" > /tmp/passwd
  echo "discourse:x:`id -u`:`id -g`:,,,:/home/discourse:/bin/bash" >> /tmp/passwd
  cat /tmp/passwd > /etc/passwd
  rm /tmp/passwd
fi

これにより、app/assets/javascripts/discourse run ember build -prodコマンド(discourse/assets.rake at tests-passed · discourse/discourse · GitHubより)が機能します。

yarn run v1.22.17
$ /discourse/app/assets/javascripts/node_modules/.bin/ember build -prod
WARNING: Node v16.13.2 is not tested against Ember CLI on your platform. We recommend that you use the most-recent "Active LTS" version of Node.js. See https://git.io/v7S5n  for details.
DEPRECATION: The integration of jQuery into Ember has been deprecated and will be removed with Ember 4.0. You can either opt-out of using jQuery, or install the `@ember/jquery` addon to provide the jQuery integration. Please consult the deprecation guide for further details: https://emberjs.com/deprecations/v3.x#toc_jquery-apis 
- Building
Environment: production
- Building
- building... 
[WARN] (broccoli-terser-sourcemap) Minifying "assets/chunk.529.6ee9018498e97f872147.js" took: 24288ms (more than 20,000ms)
...

この操作は、プリコンパイルのためだけにほぼ2GBのRAMを消費するなど、非常にコストがかかることも気づきました:scream:

よろしく、
イスマエル

「いいね!」 2

先週は4GB以上使用していましたが、最近では1GBのRAM/2GBのswapサーバーで動作させることができました。

「いいね!」 4

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.