diff --git a/modules/utils/rrutils.js b/modules/utils/rrutils.js index 3ec3ecb..d907466 100644 --- a/modules/utils/rrutils.js +++ b/modules/utils/rrutils.js @@ -3,6 +3,14 @@ const path = require("path"); const subprocess = require("child_process"); const { Regexes } = require("../constants"); +function isFlatpack() { + return !!process.env.FLATPAK_ID || process.env.container === "flatpack"; +} + +function escapeFromFlatpack(command) { + return isFlatpack() ? `flatpak-spawn --host ${command}` : command; +} + /** * @param { string } rr - Path to rr * @param { string | "" } workspaceDir - Workspace directory containing N traces @@ -10,7 +18,7 @@ const { Regexes } = require("../constants"); */ async function getTraces(rr, workspaceDir = "") { return new Promise((resolve, reject) => { - const command = `${rr} ls ${workspaceDir} -t -r`; + const command = escapeFromFlatpack(`${rr} ls ${workspaceDir} -t -r`); subprocess.exec(command, (err, stdout, stderr) => { if (err) { reject(stderr); @@ -73,7 +81,8 @@ function fallbackParseOfrrps(data) { */ async function getTraceInfo(rr, trace) { return new Promise((resolve, reject) => { - subprocess.exec(`${rr} ps ${trace}`, (error, stdout, stderr) => { + const command = escapeFromFlatpack(`${rr} ps ${trace}`); + subprocess.exec(command, (error, stdout, stderr) => { if (error) { reject(stderr); } else { @@ -149,7 +158,8 @@ const tracePicked = async (rr, traceDirectory) => { */ function getGdbInit(rr) { return new Promise((res, rej) => { - subprocess.exec(`${rr} gdbinit`, (error, stdout) => { + const command = escapeFromFlatpack(`${rr} gdbinit`); + subprocess.exec(command, (error, stdout) => { if (error) rej(error); else res(stdout.toString()); });