From 122dfbfe1427c051d18834e5dc4fd85bacebc18b Mon Sep 17 00:00:00 2001 From: cnjack Date: Thu, 21 Sep 2023 17:50:46 +0800 Subject: [PATCH] append the `--no-sandbox` when running with root user --- src/electron.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/electron.ts b/src/electron.ts index b2add49..b8d71d5 100644 --- a/src/electron.ts +++ b/src/electron.ts @@ -1,5 +1,6 @@ import path from 'node:path' import fs from 'node:fs' +import os from 'node:os' import { createRequire } from 'node:module' import { type ChildProcess, spawn } from 'node:child_process' @@ -122,6 +123,10 @@ export function startElectron(root: string | undefined): ChildProcess { const args: string[] = [] + if (os.userInfo().uid == 0 && isDev) { + args.push(`--no-sandbox`); + } + if (!!process.env.REMOTE_DEBUGGING_PORT && isDev) { args.push(`--remote-debugging-port=${process.env.REMOTE_DEBUGGING_PORT}`) }