siyuan-note/siyuan · error
create conf dir failed: %w
Error message
create conf dir failed: %w
What it means
This error occurs when SiYuan tries to create the per-notebook configuration directory `<data>/<boxID>/.siyuan` (holding sort.json) with os.MkdirAll before persisting a custom document sort order, and the OS call fails. The wrapped OS error is included via %w. It aborts the sibling-order placement of a document to avoid writing sort config into an inconsistent location.
Source
Thrown at kernel/model/file.go:3064
func (box *Box) addMaxSort(parentPath, id string) {
if err := box.placeDocInSiblingOrder(parentPath, id, "", "after"); nil != err {
logging.LogErrorf("append document sort failed: %s", err)
}
}
func (box *Box) addMinSort(parentPath, id string) {
if err := box.placeDocInSiblingOrder(parentPath, id, "", "before"); nil != err {
logging.LogErrorf("prepend document sort failed: %s", err)
}
}
func (box *Box) placeDocInSiblingOrder(parentPath, id, targetID, position string) error {
fileTreeSortLock.Lock()
confDir := filepath.Join(util.DataDir, box.ID, ".siyuan")
if err := os.MkdirAll(confDir, 0755); nil != err {
fileTreeSortLock.Unlock()
return fmt.Errorf("create conf dir failed: %w", err)
}
confPath := filepath.Join(confDir, "sort.json")
fullSortIDs, err := readSortConfMap(confPath)
if nil != err {
fileTreeSortLock.Unlock()
return err
}
currentIDs, err := loadSiblingCustomOrder(box.ID, parentPath, fullSortIDs)
if nil != err {
fileTreeSortLock.Unlock()
return err
}
orderedIDs := make([]string, 0, len(currentIDs)+1)
for _, currentID := range currentIDs {
if currentID != id {
orderedIDs = append(orderedIDs, currentID)
}
}View on GitHub (pinned to 8641553a1f)
Solutions
- Verify the notebook folder exists under the workspace data directory; recreate or re-open the notebook if it was deleted externally
- Check and fix filesystem permissions on <workspace>/data/<boxID> (writable by the kernel process user)
- Free disk space / resolve quota limits on the volume holding the workspace
- If the workspace is on a network/cloud mount, ensure it is mounted read-write and not in an offline state
- Inspect the wrapped %w error in logs for the exact OS cause
Example fix
// before (failing because notebook dir was removed)
os.MkdirAll(filepath.Join(util.DataDir, box.ID, ".siyuan"), 0755) // mkdir: no such file or directory
// after (caller-side guard: ensure the box directory exists first)
if _, err := os.Stat(filepath.Join(util.DataDir, box.ID)); os.IsNotExist(err) {
return fmt.Errorf("notebook [%s] directory is missing", box.ID)
}
if err := os.MkdirAll(filepath.Join(util.DataDir, box.ID, ".siyuan"), 0755); err != nil {
return fmt.Errorf("create conf dir failed: %w", err)
} Defensive patterns
Strategy: validation
Validate before calling
const dirOk = await fetchPost('/api/notebook/lsNotebooks', {});
const box = dirOk.data.notebooks.find(n => n.id === boxId);
if (!box) throw new Error(`Notebook ${boxId} is missing or closed`); Type guard
// Go
func boxWritable(boxID string) bool {
info, err := os.Stat(filepath.Join(util.DataDir, boxID))
return err == nil && info.IsDir()
} Try / catch
try {
await reorderDocs(sourceIDs, targetID, position);
} catch (e) {
if (String(e).includes('create conf dir failed')) {
showMsg('Notebook data directory is not writable; check permissions/disk', true);
}
} Prevention
- Keep the workspace on a local read-write volume, not an offline cloud mount
- Do not delete or rename notebook folders under data/ while SiYuan is running
- Monitor available disk space on the workspace volume
- Exclude the workspace data directory from external sync tools that rename folders mid-write
When it happens
Trigger: Calling the document sort/placement path (placeDocInSiblingOrder, reached via doc tree sort APIs) when the parent directory cannot be created: the notebook directory was deleted or renamed on disk while the kernel still knows the box, filesystem permission denies mkdir, disk full, or DataDir sits on a read-only/removable mount.
Common situations: Notebook folder removed by an external sync tool while SiYuan is running; workspace moved to a read-only volume; running as a user without write permission to the data directory; disk-quota exhaustion on the OS/Cloud-Drive mounted workspace.
Understand the failure class
Background: mkdir permission denied (EACCES): failed to create directory errors explained — this error's family across 32 libraries.
Related errors
- Query notebook failed
- Create notebook [%s] folder [%s] failed: %s
- Move notebook [%s] file [%s] failed: %s
- Remove notebook [%s] path [%s] failed: %s
- read session file failed: %w
AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11).
Data as JSON: /api/errors/9cf4a20c4501436f.
Report an issue: GitHub.