Fix Linux AppImage sandbox startup

This commit is contained in:
Mohamed Boudra
2026-03-22 01:16:38 +07:00
parent 859d234543
commit 00a2eec5f6
2 changed files with 22 additions and 4 deletions

View File

@@ -1,6 +1,12 @@
const fs = require("fs");
const path = require("path");
const EXECUTABLE_NAME = "Paseo";
const WRAPPER_MODE = 0o755;
const WRAPPER_SCRIPT = `#!/bin/bash
exec "$(dirname "$(readlink -f "$0")")/${EXECUTABLE_NAME}.bin" --no-sandbox "$@"
`;
exports.default = async function afterPack(context) {
if (context.electronPlatformName !== "linux") return;
@@ -9,4 +15,20 @@ exports.default = async function afterPack(context) {
fs.unlinkSync(chromeSandbox);
console.log("Removed chrome-sandbox from Linux build");
}
const executablePath = path.join(context.appOutDir, EXECUTABLE_NAME);
const wrappedBinaryPath = path.join(context.appOutDir, `${EXECUTABLE_NAME}.bin`);
if (!fs.existsSync(wrappedBinaryPath)) {
if (!fs.existsSync(executablePath)) {
throw new Error(`Expected Linux executable at ${executablePath}`);
}
fs.renameSync(executablePath, wrappedBinaryPath);
console.log(`Renamed ${EXECUTABLE_NAME} to ${EXECUTABLE_NAME}.bin for Linux wrapper`);
}
fs.writeFileSync(executablePath, WRAPPER_SCRIPT, { mode: WRAPPER_MODE });
fs.chmodSync(executablePath, WRAPPER_MODE);
console.log(`Created Linux wrapper for ${EXECUTABLE_NAME} with --no-sandbox`);
};

View File

@@ -21,10 +21,6 @@ import {
import { registerOpenerHandlers } from "./features/opener.js";
import { setupApplicationMenu } from "./features/menu.js";
if (process.platform === "linux") {
app.commandLine.appendSwitch("no-sandbox");
}
const DEV_SERVER_URL = process.env.EXPO_DEV_URL ?? "http://localhost:8081";
const APP_SCHEME = "paseo";
app.setName("Paseo");