From db65e001e6b13b4f7c2b37caa8e5a141676cd7f0 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Tue, 1 Mar 2022 22:24:46 +0100 Subject: [PATCH] build: fix yarn install with vendored yarn due to bug in `rules_nodejs` More details here: https://github.com/bazelbuild/rules_nodejs/pull/3350. This commit adds a little wrapper script as temporary workaround to fix CI. --- .gitignore | 1 + .yarn/yarn.js | 6 ++++++ WORKSPACE | 4 +++- 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .yarn/yarn.js diff --git a/.gitignore b/.gitignore index b25b9febb2..e7e07166c5 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,7 @@ yarn-error.log !.yarn/releases !.yarn/sdks !.yarn/versions +!.yarn/yarn.js # User specific bazel settings .bazelrc.user diff --git a/.yarn/yarn.js b/.yarn/yarn.js new file mode 100644 index 0000000000..6609421b97 --- /dev/null +++ b/.yarn/yarn.js @@ -0,0 +1,6 @@ +const {fork} = require('child_process'); + +// Wrapper script to workaround a bug in `rules_nodejs` where `.cjs` +// vendored files are not detected and launched as binaries (breaking Windows). +// TODO: Remove once https://github.com/bazelbuild/rules_nodejs/pull/3350 is available. +fork(__dirname + '/releases/yarn-3.2.0.cjs', process.argv.slice(2)); diff --git a/WORKSPACE b/WORKSPACE index cfea8e68b0..d927007bc7 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -42,6 +42,7 @@ yarn_install( args = ["--immutable"], data = [ "//:.yarn/releases/yarn-3.2.0.cjs", + "//:.yarn/yarn.js", "//:.yarnrc.yml", ], # Currently disabled due to: @@ -49,7 +50,8 @@ yarn_install( # 2. Incompatibilites with the `ts_library` rule. exports_directories_only = False, package_json = "//:package.json", - yarn = "//:.yarn/releases/yarn-3.2.0.cjs", + # TODO: Cleanup when https://github.com/bazelbuild/rules_nodejs/pull/3350 is available. + yarn = "//:.yarn/yarn.js", yarn_lock = "//:yarn.lock", )