Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Bazel does not run on Windows #1482

Closed
lukasholzer opened this issue Aug 12, 2020 · 2 comments
Closed

Bazel does not run on Windows #1482

lukasholzer opened this issue Aug 12, 2020 · 2 comments
Assignees
Labels
bazel All issues realted to bazel build system bug A broken behaviour that was working previously has-pr P1 Urgent issue that should be resolved before the next release

Comments

@lukasholzer
Copy link
Contributor

Bug Report

Currently, starting the Bazel server performing an npm install which triggers the postinstall.js script there is an incompatibility for windows so it won't run on windows. This results that currently running any Bazel target on Windows is not possible.

The first investigation was done by @andreas-doppelhofer:

diff --git a/postinstall.js b/postinstall.js
index 26810f5c..132bf5e3 100644
--- a/postinstall.js
+++ b/postinstall.js
@@ -2,6 +2,7 @@
 // migration script for the phase where we support building with bazel
 // and without.
 const { exec } = require('child_process');
+const { execFile } = require('child_process');
 const { resolve } = require('path');
 const { sync } = require('glob');
 const { writeFileSync, readFileSync } = require('fs');
@@ -20,10 +21,18 @@ async function main() {
   // Generate Angular ngfactory.js, ngsummary.js files for the dependencies,
   // that are needed for ViewEngine
-  await execCommand(`${NGC_BINARY} -p view-engine-tsconfig.json`);
+  console.log("DOPS da bin ich");
+  await execCommand(`dir view-engine-tsconfig.json`);
+  await execCommand(`dir ${NGC_BINARY}`);
+
+  await execFileCommand(NGC_BINARY,["-p","view-engine-tsconfig.json"])
+  //await execCommand(`${NGC_BINARY} -p view-engine-tsconfig.json`);
   // Generate Ivy entry points
-  await execCommand(
-    `${NGCC_BINARY} --properties es2015 browser module main --first-only --create-ivy-entry-points`,
+  //await execCommand(
+  //  `${NGCC_BINARY} --properties es2015 browser module main --first-only --create-ivy-entry-points`,
+  //  );
+  await execFileCommand(
+    NGCC_BINARY,["--properties","es2015","browser","module","main","--first-only","--create-ivy-entry-points"],
   );
   // link the ivy entry points
   updateNgccMainFields();
@@ -33,6 +42,25 @@ async function main() {
   }
 }
+/**
+ * Executes a file and return it as a Promise.
+ * @param cmd {string}
+ * @return {Promise<string>}
+ */
+function execFileCommand(_cmd, _args) {
+  return new Promise((resolve, reject) => {
+    console.log("DOPS " + _cmd + " " + _args);
+    execFile(_cmd,_args, {shell: true}, (error, stdout, stderr) => {
+      if (error) {
+        return reject(error);
+      }
+      const output = stdout ? stdout : stderr;
+      console.log(output);
+      resolve(output);
+    });
+  });
+}
+
 /**
  * Executes a shell command and return it as a Promise.
  * @param cmd {string}
@@ -40,7 +68,7 @@ async function main() {
  */
 function execCommand(cmd) {
   return new Promise((resolve, reject) => {
-    exec(cmd, (error, stdout, stderr) => {
+    exec(cmd, {shell: true}, (error, stdout, stderr) => {
       if (error) {
         return reject(error);
       }
@lukasholzer lukasholzer added bug A broken behaviour that was working previously P1 Urgent issue that should be resolved before the next release labels Aug 12, 2020
@lukasholzer lukasholzer self-assigned this Aug 12, 2020
@lukasholzer lukasholzer added bazel All issues realted to bazel build system has-pr labels Aug 12, 2020
lukasholzer pushed a commit that referenced this issue Aug 18, 2020
To run the posinstall scripts on windows as well use shelljs a platform independent shell command execution.

Fixes #1482
lukasholzer pushed a commit that referenced this issue Aug 18, 2020
To run the posinstall scripts on windows as well use shelljs a platform independent shell command execution.

Fixes #1482
lukasholzer pushed a commit that referenced this issue Aug 18, 2020
To run the posinstall scripts on windows as well use shelljs a platform independent shell command execution.

Fixes #1482
@SkaillZ
Copy link
Contributor

SkaillZ commented Aug 27, 2020

@lukasholzer
Copy link
Contributor Author

Status update

Could track down the problem on two smaller problems.

  1. Bazels npm_install rule does not work with using third party npm dependencies inside the postinstall script. (a switch to yarn would work – but this would be a lot of work)
  2. Executing nodejs_test on windows fails. Jest Example fails on Windows bazel-contrib/rules_nodejs#1454

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bazel All issues realted to bazel build system bug A broken behaviour that was working previously has-pr P1 Urgent issue that should be resolved before the next release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants