{"record":{"id":"00b3129de0022f79","repo":"siyuan-note/siyuan","slug":"read-workspace-conf-s-failed-s","errorCode":null,"errorMessage":"read workspace conf [%s] failed: %s","messagePattern":"read workspace conf \\[(.+?)\\] failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/util/working.go","lineNumber":419,"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":401,"sourceCodeEnd":437,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/util/working.go#L401-L437","documentation":"ReadWorkspacePaths in kernel/util/working.go loads the list of known workspace paths from ~/.config/siyuan/workspace.json. If os.ReadFile fails, it logs and returns \"read workspace conf [<path>] failed: <err>\".","triggerScenarios":"workspace.json does not exist on first run, is unreadable due to permissions, or HomeDir points to a directory where .config/siyuan was deleted or never created.","commonSituations":"Fresh installs before the config file is created, HOME not set correctly in service/container contexts, config directory removed by cleanup scripts, read-only home mounts.","solutions":["Verify the file exists at <HomeDir>/.config/siyuan/workspace.json","Check file permissions on the config directory and file","Confirm HOME (or the platform equivalent) resolves to the expected user directory","On first run, treat a missing file as an empty workspace list instead of an error","Restore the file from backup or recreate it with a JSON array of workspace paths"],"exampleFix":"// before\ndata, err := os.ReadFile(workspaceConf)\nif err != nil {\n\tmsg := fmt.Sprintf(\"read workspace conf [%s] failed: %s\", workspaceConf, err)\n\tlogging.LogError(msg)\n\terr = errors.New(msg)\n\treturn\n}\n// after: tolerate a missing file on first run\nif errors.Is(err, fs.ErrNotExist) {\n\tret = []string{}\n\terr = nil\n\treturn\n}","handlingStrategy":"fallback","validationCode":"// check config presence before relying on workspace list\nconfPath := filepath.Join(home, \".config\", \"siyuan\", \"workspace.json\")\nif _, err := os.Stat(confPath); os.IsNotExist(err) {\n\t// first run: use empty workspace list\n}","typeGuard":null,"tryCatchPattern":"paths, err := util.ReadWorkspacePaths()\nif err != nil && strings.HasPrefix(err.Error(), \"read workspace conf\") {\n\tpaths = []string{} // degrade to empty list on first run\n}","preventionTips":["Never hand-delete ~/.config/siyuan while the kernel runs","Verify HOME resolves correctly in service/container deployments","Keep config directory writable by the kernel user","Create the config file via WriteWorkspacePaths, not ad-hoc writes"],"tags":["config","filesystem","workspace"],"backgroundTag":"config-file-not-found","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"}