{"record":{"id":"79f57418223b7639","repo":"siyuan-note/siyuan","slug":"1","errorCode":"-1","errorMessage":"read workspace conf [%s] failed: %s","messagePattern":"read workspace conf \\[(.+?)\\] failed: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"kernel/util/working.go","lineNumber":404,"sourceCode":"\ttargetLower := strings.ToLower(target)\n\tvar result []string\n\tfor _, p := range paths {\n\t\tif strings.ToLower(p) == targetLower {\n\t\t\tcontinue\n\t\t}\n\t\tresult = append(result, p)\n\t}\n\treturn result\n}\n\nfunc ReadWorkspacePaths() (ret []string, err error) {\n\tret = []string{}\n\tworkspaceConf := filepath.Join(HomeDir, \".config\", \"siyuan\", \"workspace.json\")\n\tdata, err := os.ReadFile(workspaceConf)\n\tif err != nil {\n\t\tmsg := fmt.Sprintf(\"read 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 = gulu.JSON.UnmarshalJSON(data, &ret); err != nil {\n\t\tmsg := fmt.Sprintf(\"unmarshal 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\tvar tmp []string\n\tworkspaceBaseDir := filepath.Dir(HomeDir)\n\tfor _, d := range ret {\n\t\tif ContainerIOS == Container && strings.Contains(d, \"/Documents/\") {\n\t\t\t// iOS 端沙箱路径会变化，需要转换为相对路径再拼接当前沙箱中的工作空间基路径\n\t\t\td = d[strings.Index(d, \"/Documents/\")+len(\"/Documents/\"):]\n\t\t\td = filepath.Join(workspaceBaseDir, d)\n\t\t}","sourceCodeStart":386,"sourceCodeEnd":422,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/util/working.go#L386-L422","documentation":"Logged and returned at working.go:404 when os.ReadFile of the workspace config (~/.config/siyuan/workspace.json, built from HomeDir at working.go:399) fails. code=-1 marks it as a generic (non-SiYuan-specific) error. The file holds the list of recently used workspace directory paths. Note: on a genuinely fresh install the file does not exist yet, so callers must treat not-exist as benign.","triggerScenarios":"First run before any workspace has been chosen (file absent), permission denied on ~/.config/siyuan, the directory was moved/deleted out of band, another process holds an incompatible handle, or the path is on an unavailable volume.","commonSituations":"Fresh install, user manually deleted workspace.json, HomeDir mis-detected on a portable/custom layout, snap/flatpak confinement, read-only home.","solutions":["Treat a not-exist error as non-fatal and let the user pick a workspace to regenerate the file.","Ensure ~/.config/siyuan exists and is writable by the SiYuan process.","If the file was deleted by mistake, choose a workspace once — WriteWorkspacePaths recreates it.","On sandboxed installs, confirm HomeDir resolves inside the writable sandbox."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// Treat a missing workspace.json as benign (fresh install),\n// and only act on other read errors.\nfunc workspaceConfReadable() error {\n    p := filepath.Join(util.HomeDir, \".config\", \"siyuan\", \"workspace.json\")\n    _, err := os.Stat(p)\n    if err == nil {\n        return nil\n    }\n    if os.IsNotExist(err) {\n        return nil // expected on first run\n    }\n    return err\n}","typeGuard":"func isReadWorkspaceConfFailed(err error) bool {\n    return err != nil && strings.HasPrefix(err.Error(), \"read workspace conf\")\n}","tryCatchPattern":"paths, err := util.ReadWorkspacePaths()\nif err != nil {\n    if os.IsNotExist(underlyingOSErr(err)) {\n        paths = nil // first run: prompt the user to pick a workspace\n    } else {\n        // fall back to a default workspace location\n        paths = []string{defaultWorkspacePath()}\n    }\n}","preventionTips":["On fresh installs, expect this file to be absent — handle not-exist as a normal case.","Ensure ~/.config/siyuan is writable so the file can be (re)created.","Do not delete workspace.json casually; if you do, pick a workspace once to regenerate it."],"tags":["config","filesystem","workspace","startup"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}