From 5583171fa7a99f8b77ac233d2759a0159aa03e47 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Sun, 20 Nov 2022 21:33:35 +0800 Subject: [PATCH] fallback if no zig --- cli/src/build.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cli/src/build.ts b/cli/src/build.ts index 8eaad78b96..253201246f 100644 --- a/cli/src/build.ts +++ b/cli/src/build.ts @@ -305,6 +305,21 @@ export class BuildCommand extends Command { } if (this.useZig || isCrossForLinux || isCrossForMacOS) { + try { + execSync('zig version') + } catch (e) { + if (this.useZig) { + throw new TypeError( + `Could not find ${chalk.green('zig')} on the PATH`, + ) + } else { + debug( + `Could not find ${chalk.green( + 'zig', + )} on the PATH, fallback to normal linker`, + ) + } + } const zigABIVersion = this.zigABIVersion ?? (isCrossForLinux && triple.abi === 'gnu') ? DEFAULT_GLIBC_TARGET