resolve a relative task cwd against the user's home before spawning
the file browser sends msg.cwd relative to the user's home and it went straight to Bun.spawn, which resolves it against the server's cwd. when that directory does not exist posix_spawn reports ENOENT naming the binary rather than the directory, so "Convert Audio" failed with the misleading "posix_spawn 'bash'". Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import type { ServerWebSocket } from 'bun';
|
||||
import { join } from 'node:path';
|
||||
import { join, isAbsolute } from 'node:path';
|
||||
import { mkdirSync, writeFileSync, chmodSync, rmSync } from 'node:fs';
|
||||
import { getTaskByDirName } from 'officerdb';
|
||||
import { getHomeDirForRole, DATA_PATH } from '../../data-path';
|
||||
@@ -124,9 +124,10 @@ async function handleRun(ws: ServerWebSocket<WSData>, msg: RunMessage) {
|
||||
const runner = getRunner(language);
|
||||
const cmd = [...runner, scriptPath, ...positionalArgs];
|
||||
|
||||
// Resolve cwd
|
||||
// msg.cwd arrives from the file browser relative to the user's home; Bun.spawn needs it absolute
|
||||
// (a missing cwd surfaces as ENOENT naming the binary, not the directory)
|
||||
const homeDir = getHomeDirForRole(email, role);
|
||||
const cwd = msg.cwd ?? homeDir;
|
||||
const cwd = msg.cwd ? (isAbsolute(msg.cwd) ? msg.cwd : join(homeDir, msg.cwd)) : homeDir;
|
||||
|
||||
let spawnCmd: string[];
|
||||
let spawnEnv: Record<string, string>;
|
||||
|
||||
Reference in New Issue
Block a user