different-ai/openwork · error
OpenCode is not configured for a local workspace
Error message
OpenCode is not configured for a local workspace
What it means
engineRestart() restarts the engine in the workspace it was previously started in, read from engineState.projectDir. If there is no current projectDir — the engine was never started, or was started without a local workspace (e.g. remote-access-only mode) — this error is thrown. Restart is only defined for a configured local workspace.
Source
Thrown at apps/desktop/electron/runtime.mjs:2185
lifecycleState = "healthy";
return snapshotEngineState(engineState);
} catch (error) {
lifecycleState = "error";
throw error;
}
}
async function engineStop() {
lifecycleState = "stopping";
await stopAllRuntimeChildren();
lifecycleState = "idle";
return snapshotEngineState(engineState);
}
async function engineRestart(options = {}) {
const projectDir = engineState.projectDir;
if (!projectDir) {
throw new Error("OpenCode is not configured for a local workspace");
}
const openworkRemoteAccess = typeof options.openworkRemoteAccess === "boolean"
? options.openworkRemoteAccess
: openworkServerState.remoteAccessEnabled;
return engineStart(projectDir, {
runtime: engineState.runtime,
workspacePaths: [projectDir],
opencodeEnableExa: options.opencodeEnableExa,
openworkRemoteAccess,
forceRestart: true,
});
}
async function engineInfo() {
if (inProcessServer?.managedOpencode) {
engineState.managedPid = inProcessServer.managedOpencode.pid ?? null;
}
return { ...snapshotEngineState(engineState), lifecycleState };View on GitHub (pinned to 2b7df46e8a)
Solutions
- Call engineStart(projectDir) first to establish a local workspace, then restart as needed.
- Check engineState (or snapshotEngineState) for a non-empty projectDir before offering/invoking restart.
- Disable or hide the Restart action in the UI when no local workspace is active.
- If state was cleared unexpectedly, fix the code path that reset engineState (e.g. on stop or error) to preserve projectDir.
Example fix
// before
await engineRestart(); // throws if never started
// after
if (snapshotEngineState(engineState).projectDir) {
await engineRestart();
} else {
await engineStart(await pickWorkspaceDir());
} Defensive patterns
Strategy: validation
Validate before calling
const state = snapshotEngineState(engineState);
if (!state.projectDir) {
throw new Error("No local workspace configured; call engineStart first");
}
await engineRestart(); Type guard
function canRestart(state) {
return typeof state?.projectDir === "string" && state.projectDir.trim().length > 0;
} Try / catch
try {
await engineRestart();
} catch (err) {
if (err.message === "OpenCode is not configured for a local workspace") {
await engineStart(persistedLastWorkspaceDir ?? (await pickWorkspaceDir()));
} else { throw err; }
} Prevention
- Only enable Restart UI affordances when engineState.projectDir is set.
- Persist projectDir across app restarts so auto-restart has a workspace to use.
- After engine stop/error, decide explicitly whether to clear or retain projectDir.
- For remote-access sessions, route restart through the remote path instead of the local engine restart.
When it happens
Trigger: Calling engineRestart() before any engineStart() succeeded, after engine stop cleared engineState.projectDir, or when the engine was configured for a remote workspace so no local projectDir exists.
Common situations: App boots and auto-restart fires with no prior session; a crash handler restarts the engine after state was reset; user hits 'Restart' on a fresh window; workspace switched to remote access so projectDir is intentionally absent.
Related errors
- This cloud provider has not been imported into the workspace
- Agent context diagnostics timeout must be between 1 ms and 3
- Invalid cloud provider sync response.
- Invalid cloud provider sync status.
- Invalid cloud provider sync status response.
AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01).
Data as JSON: /api/errors/c15f5a0ec58f9959.
Report an issue: GitHub.