{"record":{"id":"8d852179141dd2fc","repo":"siyuan-note/siyuan","slug":"write-workspace-conf-s-failed-s","errorCode":null,"errorMessage":"write workspace conf [%s] failed: %s","messagePattern":"write workspace conf \\[(.+?)\\] failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/util/working.go","lineNumber":466,"sourceCode":"\tret = DeduplicateWorkspacePaths(ret)\n\treturn\n}\n\nfunc WriteWorkspacePaths(workspacePaths []string) (err error) {\n\tworkspacePaths = DeduplicateWorkspacePaths(workspacePaths)\n\tworkspaceConf := filepath.Join(HomeDir, \".config\", \"siyuan\", \"workspace.json\")\n\tdata, err := gulu.JSON.MarshalJSON(workspacePaths)\n\tif err != nil {\n\t\tmsg := fmt.Sprintf(\"marshal workspace conf [%s] failed: %s\", workspaceConf, err)\n\t\tlogging.LogError(msg)\n\t\terr = errors.New(msg)\n\t\treturn\n\t}\n\n\tif err = filelock.WriteFile(workspaceConf, data); err != nil {\n\t\tmsg := fmt.Sprintf(\"write workspace conf [%s] failed: %s\", workspaceConf, err)\n\t\tlogging.LogError(msg)\n\t\terr = errors.New(msg)\n\t\treturn\n\t}\n\treturn\n}\n\nvar (\n\tServerURL  *url.URL // 内核服务 URL\n\tServerPort = \"0\"    // HTTP/WebSocket 端口，0 为使用随机端口\n\n\tReadOnly       bool\n\tAccessAuthCode string\n\tLang           = \"\"\n\n\tContainer        string // docker, android, ios, harmony, std\n\tISMicrosoftStore bool   // 桌面端是否是微软商店版\n)\n\nconst (","sourceCodeStart":448,"sourceCodeEnd":484,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/util/working.go#L448-L484","documentation":"I/O failure report in WriteWorkspacePaths: filelock.WriteFile could not persist the workspace path list to ~/.config/siyuan/workspace.json. This fires on disk errors such as missing directory, permission denial, or a locked file while saving multi-window workspace configuration; callers include Close, initWorkspaceDir, and the mobile variant.","triggerScenarios":"The .config/siyuan directory is missing or read-only, disk is full, another SiYuan instance holds a conflicting file lock, or the filesystem denies writes (permissions, read-only mount).","commonSituations":"Read-only home directory or sandboxed app containers, full disk, config directory owned by another user, multiple kernel instances racing on the same workspace config.","solutions":["Check write permissions on <HomeDir>/.config/siyuan and ensure the directory exists","Free disk space if the volume is full","Close other running SiYuan instances that may hold the file lock","Check the wrapped error for permission-denied vs read-only-filesystem specifics and remount/chown accordingly"],"exampleFix":"// ensure the config directory exists before writing\nif err := os.MkdirAll(filepath.Dir(workspaceConf), 0755); err != nil {\n\treturn err\n}\nif err = filelock.WriteFile(workspaceConf, data); err != nil {\n\treturn fmt.Errorf(\"write workspace conf [%s] failed: %w\", workspaceConf, err)\n}","handlingStrategy":"try-catch","validationCode":"// ensure directory is writable beforehand\ninfo, err := os.Stat(confDir)\nif err != nil || !info.IsDir() { os.MkdirAll(confDir, 0755) }\nif unix.Access(confDir, unix.W_OK) != nil { /* surface permission problem early */ }","typeGuard":null,"tryCatchPattern":"err := util.WriteWorkspacePaths(paths)\nif err != nil && strings.Contains(err.Error(), \"write workspace conf\") {\n\t// check disk space, permissions, and competing instances before retrying\n}","preventionTips":["Keep ~/.config/siyuan writable and on a non-full volume","Run only one kernel instance per workspace config","Avoid read-only home mounts for app data"],"tags":["filesystem","config","write","filelock"],"backgroundTag":"file-write-failed","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}