From 03eea8a90fd4bc750bc30bc047915eb7f33b74fe Mon Sep 17 00:00:00 2001 From: Chris Tate Date: Mon, 2 Feb 2026 21:28:23 -0600 Subject: [PATCH] fix: auto-chmod binary on first run to fix EACCES on macOS (#354) Bun blocks postinstall scripts by default, leaving the binary without execute permissions. The wrapper now fixes this automatically. Fixes #344 --- bin/agent-browser.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/bin/agent-browser.js b/bin/agent-browser.js index ee97cf3..4933947 100755 --- a/bin/agent-browser.js +++ b/bin/agent-browser.js @@ -9,7 +9,7 @@ */ import { spawn } from 'child_process'; -import { existsSync } from 'fs'; +import { existsSync, accessSync, chmodSync, constants } from 'fs'; import { dirname, join } from 'path'; import { fileURLToPath } from 'url'; import { platform, arch } from 'os'; @@ -73,6 +73,23 @@ function main() { process.exit(1); } + // Ensure binary is executable (fixes EACCES on macOS/Linux when postinstall didn't run, + // e.g., when using bun which blocks lifecycle scripts by default) + if (platform() !== 'win32') { + try { + accessSync(binaryPath, constants.X_OK); + } catch { + // Binary exists but isn't executable - fix it + try { + chmodSync(binaryPath, 0o755); + } catch (chmodErr) { + console.error(`Error: Cannot make binary executable: ${chmodErr.message}`); + console.error('Try running: chmod +x ' + binaryPath); + process.exit(1); + } + } + } + // Spawn the native binary with inherited stdio const child = spawn(binaryPath, process.argv.slice(2), { stdio: 'inherit',