{"record":{"id":"0ec834e8f2ef5d5b","repo":"different-ai/openwork","slug":"failed-to-write-opencode-openwork-json","errorCode":null,"errorMessage":"Failed to write .opencode/openwork.json","messagePattern":"Failed to write \\.opencode/openwork\\.json","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/app/src/react-app/domains/settings/state/extensions-store.ts","lineNumber":549,"sourceCode":"      hasOpenworkTarget &&\n      openworkSnapshot.openworkServerCapabilities?.config?.write !== false;\n\n    if (canUseOpenworkServer && openworkClient && openworkWorkspaceId) {\n      await openworkClient.patchConfig(openworkWorkspaceId, { openwork: config });\n      return true;\n    }\n\n    if (hasOpenworkTarget) {\n      return false;\n    }\n\n    if (isLocalWorkspace && isDesktopRuntime() && root) {\n      const result = (await workspaceOpenworkWrite({\n        workspacePath: root,\n        config: config as never,\n      })) as { ok: boolean; stderr?: string; stdout?: string };\n      if (!result.ok) {\n        throw new Error(result.stderr || result.stdout || \"Failed to write .opencode/openwork.json\");\n      }\n      return true;\n    }\n\n    return false;\n  };\n\n  const refreshPendingCloudPluginChanges = async (installedPlugins?: Record<string, CloudImportedPlugin>) => {\n    try {\n      const target = await resolveWorkspaceServerTarget();\n      if (!target.openworkClient || !target.openworkWorkspaceId) {\n        setStateField(\"pendingCloudPluginChanges\", {});\n        return;\n      }\n      const syncResult = await refreshDesktopCloudSync({\n        openworkClient: target.openworkClient,\n        workspaceId: target.openworkWorkspaceId,\n      }).catch(() => null);","sourceCodeStart":531,"sourceCodeEnd":567,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/app/src/react-app/domains/settings/state/extensions-store.ts#L531-L567","documentation":"createExtensionsStore writes the workspace .opencode/openwork.json config via the desktop bridge (workspaceOpenworkWrite) for local desktop workspaces. When the bridge reports result.ok === false, the store throws, surfacing the bridge's stderr/stdout if present, else the generic message. It indicates the config file could not be persisted to disk.","triggerScenarios":"Persisting extensions/marketplace/plugin config when workspaceOpenworkWrite resolves with { ok: false } — e.g. the workspace directory lacks .opencode write permission, the path is read-only, or the bridge spawn fails and reports no stderr/stdout.","commonSituations":"Workspace folder owned by another user or opened read-only; disk full; .opencode directory created with wrong permissions; antivirus or OS blocking file writes; bridge unable to locate the workspace path (moved/renamed folder).","solutions":["Read result.stderr/stdout (the thrown error includes it) to see the underlying write failure and fix it (permissions, path).","Check the workspace folder and .opencode directory are writable by the app user.","Verify the workspace path still exists on disk; re-select the workspace if it moved.","Retry the persistence action after resolving filesystem issues."],"exampleFix":"// before\nif (!result.ok) {\n  throw new Error(result.stderr || result.stdout || \"Failed to write .opencode/openwork.json\");\n}\n// after\nif (!result.ok) {\n  const detail = result.stderr || result.stdout || \"unknown bridge failure\";\n  toast.error(`Could not save extension config: ${detail}. Check that the workspace folder is writable.`);\n  return false;\n}","handlingStrategy":"try-catch","validationCode":"const probe = await workspaceOpenworkWrite({ workspacePath: root, config: { __probe: true } });\nif (!probe.ok) console.error(\"workspace config not writable:\", probe.stderr);","typeGuard":null,"tryCatchPattern":"try {\n  await saveExtensionConfig(config);\n} catch (err) {\n  if (err.message.includes(\".opencode/openwork.json\")) toast.error(`Check workspace folder permissions: ${err.message}`);\n  else throw err;\n}","preventionTips":["Verify workspace folder write permissions when opening/adding a workspace","Create .opencode with correct permissions at workspace setup time","Surface the bridge stderr/stdout detail to users, not just the generic message"],"tags":["filesystem","config-write","desktop","permissions"],"backgroundTag":"file-write-permission-denied","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}