siyuan-note/siyuan · error · errObsidianVaultUnreadable

: read Vault config directory

Error message

%w: read Vault config directory: %v

What it means

os.Lstat on the vault's `.obsidian` configuration directory failed with an error other than NotExist, so the importer cannot determine whether the selected directory is a real Obsidian Vault. It is wrapped in errObsidianVaultUnreadable to signal an environment/OS-level failure rather than a missing-config condition.

Solutions

  1. Fix permissions on the Vault directory so the SiYuan process can traverse it (chmod/chown or grant read access)
  2. Check for symlink loops or unusual files named `.obsidian` and remove/repair them
  3. Run SiYuan under a user account that can access the Vault location
  4. If the directory genuinely has no readable `.obsidian`, move the Vault to an accessible location
Defensive patterns

Strategy: validation

Validate before calling

const fs = require('fs');
try { fs.accessSync(require('path').join(vaultPath, '.obsidian'), fs.constants.R_OK); } catch (e) {
  if (e.code !== 'ENOENT') console.error('cannot stat .obsidian:', e.message);
}

Prevention

When it happens

Trigger: validateObsidianVaultRoot calls os.Lstat(filepath.Join(abs, ".obsidian")) and statErr is neither nil nor os.IsNotExist — e.g. EACCES (parent dir not searchable), ELOOP (symlink loop), ENOTDIR (`.obsidian` exists as a path component over a file on some systems).

Common situations: Vault directory has restrictive Unix permissions (e.g. another user's home directory); filesystem mounted with no access; Windows ACLs denying traversal; a broken link cycle named `.obsidian`.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


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

Appendix: source

Thrown at kernel/model/import_obsidian.go:589

		return "", errObsidianVaultNotDirectory
	}
	if info.Mode()&os.ModeSymlink != 0 || isObsidianResolvedLink(abs) {
		return "", fmt.Errorf("%w: Vault root is a symbolic link or reparse point", errObsidianVaultUnsafePath)
	}
	if util.IsSensitivePath(abs) {
		return "", fmt.Errorf("%w: selected Vault path is sensitive", errObsidianVaultUnsafePath)
	}
	workspace, _ := filepath.Abs(filepath.Clean(util.WorkspaceDir))
	if sameObsidianPath(abs, workspace) || gulu.File.IsSubPath(workspace, abs) || gulu.File.IsSubPath(abs, workspace) {
		return "", fmt.Errorf("%w: Vault root and SiYuan workspace contain each other", errObsidianVaultUnsafePath)
	}
	configPath := filepath.Join(abs, ".obsidian")
	configInfo, statErr := os.Lstat(configPath)
	if statErr != nil {
		if os.IsNotExist(statErr) {
			return "", errObsidianVaultConfigMissing
		}
		return "", fmt.Errorf("%w: read Vault config directory: %v", errObsidianVaultUnreadable, statErr)
	}
	if !configInfo.IsDir() || configInfo.Mode()&os.ModeSymlink != 0 || isObsidianResolvedLink(configPath) {
		return "", errObsidianVaultConfigMissing
	}
	return abs, nil
}

func scanObsidianVaultFiles(ctx context.Context, vault *obsidianVaultContext, relDir, absDir string) error {
	if err := ctx.Err(); err != nil {
		return err
	}
	entries, err := os.ReadDir(absDir)
	if err != nil {
		return fmt.Errorf("read Vault directory [%s]: %w", relDir, err)
	}
	sort.Slice(entries, func(i, j int) bool { return strings.ToLower(entries[i].Name()) < strings.ToLower(entries[j].Name()) })
	for _, entry := range entries {
		if err = ctx.Err(); err != nil {

View on GitHub (pinned to 9f775e8a12)