From 2dbd70484e65ae57e18c323381136077cd00adad Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Sat, 22 Aug 2026 12:37:35 +0200 Subject: fix: find meshbay-node in ~/.local/bin when not in PATH Electron does not run in a login shell, so ~/.local/bin is not in PATH and `which meshbay-node` fails. Check that well-known location first in both node:installed and the node:start fallback. Co-Authored-By: Claude Opus 4.6 --- packages/meshbay-client/src/main.js | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'packages/meshbay-client/src/main.js') diff --git a/packages/meshbay-client/src/main.js b/packages/meshbay-client/src/main.js index 8dcc2ae..bfa9b48 100644 --- a/packages/meshbay-client/src/main.js +++ b/packages/meshbay-client/src/main.js @@ -714,15 +714,28 @@ function registerBridge() { } }); + function findNodeBinary() { + const local = path.join(os.homedir(), '.local', 'bin', 'meshbay-node'); + if (fs.existsSync(local)) return local; + return new Promise((resolve) => { + execFile('which', ['meshbay-node'], (err, stdout) => { + resolve(err ? null : stdout.trim()); + }); + }); + } + ipcMain.handle('node:installed', async () => { if (process.platform !== 'linux') return { installed: false }; - return new Promise((resolve) => { + const unit = await new Promise((resolve) => { execFile('systemctl', ['--user', 'show', 'meshbay-node.service', '--property=LoadState'], (err, stdout) => { - if (err) return resolve({ installed: false }); - resolve({ installed: stdout.trim() === 'LoadState=loaded' }); + if (err) return resolve(false); + resolve(stdout.trim() === 'LoadState=loaded'); }); }); + if (unit) return { installed: true }; + const bin = await findNodeBinary(); + return { installed: Boolean(bin) }; }); async function probeNode() { @@ -826,11 +839,7 @@ function registerBridge() { // Fallback: start the binary directly (dev mode, or no unit installed). if (!launched) { - const binPath = await new Promise((resolve) => { - execFile('which', ['meshbay-node'], (err, stdout) => { - resolve(err ? null : stdout.trim()); - }); - }); + const binPath = await findNodeBinary(); if (!binPath) { throw new Error( 'meshbay-node is not installed'); -- cgit v1.2.3