siyuan-note/siyuan · error

read workspace conf [ ] failed

Error message

read workspace conf [%s] failed: %s

What it means

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>".

Solutions

  1. Verify the file exists at <HomeDir>/.config/siyuan/workspace.json
  2. Check file permissions on the config directory and file
  3. Confirm HOME (or the platform equivalent) resolves to the expected user directory
  4. On first run, treat a missing file as an empty workspace list instead of an error
  5. Restore the file from backup or recreate it with a JSON array of workspace paths

Example fix

// before
data, err := os.ReadFile(workspaceConf)
if err != nil {
	msg := fmt.Sprintf("read workspace conf [%s] failed: %s", workspaceConf, err)
	logging.LogError(msg)
	err = errors.New(msg)
	return
}
// after: tolerate a missing file on first run
if errors.Is(err, fs.ErrNotExist) {
	ret = []string{}
	err = nil
	return
}
Defensive patterns

Strategy: fallback

Validate before calling

// check config presence before relying on workspace list
confPath := filepath.Join(home, ".config", "siyuan", "workspace.json")
if _, err := os.Stat(confPath); os.IsNotExist(err) {
	// first run: use empty workspace list
}

Try / catch

paths, err := util.ReadWorkspacePaths()
if err != nil && strings.HasPrefix(err.Error(), "read workspace conf") {
	paths = []string{} // degrade to empty list on first run
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Config file not found": what it means and how to fix it in docker-sync, Maven, Vagrant, Turborepo and other tools — this error's family across 60 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/00b3129de0022f79. Report an issue: GitHub.

Appendix: source

Thrown at kernel/util/working.go:419

	targetLower := strings.ToLower(target)
	var result []string
	for _, p := range paths {
		if strings.ToLower(p) == targetLower {
			continue
		}
		result = append(result, p)
	}
	return result
}

func ReadWorkspacePaths() (ret []string, err error) {
	ret = []string{}
	workspaceConf := filepath.Join(HomeDir, ".config", "siyuan", "workspace.json")
	data, err := os.ReadFile(workspaceConf)
	if err != nil {
		msg := fmt.Sprintf("read workspace conf [%s] failed: %s", workspaceConf, err)
		logging.LogError(msg)
		err = errors.New(msg)
		return
	}

	if err = gulu.JSON.UnmarshalJSON(data, &ret); err != nil {
		msg := fmt.Sprintf("unmarshal workspace conf [%s] failed: %s", workspaceConf, err)
		logging.LogError(msg)
		err = errors.New(msg)
		return
	}

	var tmp []string
	workspaceBaseDir := filepath.Dir(HomeDir)
	for _, d := range ret {
		if ContainerIOS == Container && strings.Contains(d, "/Documents/") {
			// iOS 端沙箱路径会变化,需要转换为相对路径再拼接当前沙箱中的工作空间基路径
			d = d[strings.Index(d, "/Documents/")+len("/Documents/"):]
			d = filepath.Join(workspaceBaseDir, d)
		}

View on GitHub (pinned to 9f775e8a12)