fix(bootstrap): create workspace dir before setting openclaw config

On fresh Linux installs (e.g. running as root), `openclaw config set
agents.defaults.workspace` fails because the target directory doesn't
exist yet — some OpenClaw builds validate the path on disk before
accepting the value. Create the directory eagerly with mkdirSync before
the config set call.

Also surface the exit code in runOpenClawOrThrow errors when stderr is
empty, so silent failures are easier to diagnose.

Fixes #101
This commit is contained in:
kumarabhirup 2026-03-15 04:29:07 -07:00
parent d6ca3b329c
commit 1c92aaf5d7
No known key found for this signature in database
GPG Key ID: DB7CA2289CAB0167

View File

@ -747,7 +747,10 @@ async function runOpenClawOrThrow(params: {
return result;
}
const detail = firstNonEmptyLine(result.stderr, result.stdout);
throw new Error(detail ? `${params.errorMessage}\n${detail}` : params.errorMessage);
const parts = [params.errorMessage];
if (detail) parts.push(detail);
else if (result.code != null) parts.push(`(exit code ${result.code})`);
throw new Error(parts.join("\n"));
}
/**
@ -770,7 +773,10 @@ async function runOpenClawInteractiveOrThrow(params: {
return result;
}
const detail = firstNonEmptyLine(result.stderr, result.stdout);
throw new Error(detail ? `${params.errorMessage}\n${detail}` : params.errorMessage);
const parts = [params.errorMessage];
if (detail) parts.push(detail);
else if (result.code != null) parts.push(`(exit code ${result.code})`);
throw new Error(parts.join("\n"));
}
/**
@ -2223,6 +2229,9 @@ export async function bootstrapCommand(
// Pin OpenClaw to the managed default workspace before onboarding so bootstrap
// never drifts into creating/using legacy workspace-* paths.
// The directory must exist before `openclaw config set` — some OpenClaw builds
// validate the workspace path on disk before accepting the value.
mkdirSync(workspaceDir, { recursive: true });
preCloudSpinner?.message("Configuring default workspace…");
await ensureDefaultWorkspacePath(openclawCommand, profile, workspaceDir);