siyuan-note/siyuan · error

localized message from Conf.Language(6) formatted with…

Error message

localized message from Conf.Language(6) formatted with box.Name, path, err (mkdir all failed)

What it means

Box.MkdirAll creates a directory tree inside a notebook. On os.MkdirAll failure it formats a localized message via Conf.Language(6) with box name, path, and the OS error, logs the detail, and returns the message. Called internally by moveDoc when recreating destination directories during a document move.

Solutions

  1. Verify no file exists with the same name as an intermediate path segment
  2. Ensure the notebook directory is writable and the volume mounted
  3. Shorten the target path on Windows or enable long-path support
  4. Check the kernel log for the 'mkdir all [path=...] failed' entry to get the exact OS error
Defensive patterns

Strategy: validation

Validate before calling

// Go: ensure no intermediate segment is a regular file
for seg := path; seg != "." && seg != "/" && seg != ""; seg = filepath.Dir(seg) {
    if util.IsExist(filepath.Join(util.DataDir, box.ID, seg)) &&
        !gulu.File.IsDir(filepath.Join(util.DataDir, box.ID, seg)) {
        return fmt.Errorf("%s is a file, not a directory", seg)
    }
}

Try / catch

if err := box.MkdirAll(path); err != nil {
    // localized message; see kernel log 'mkdir all [path=...] failed'
    return err
}

Prevention

When it happens

Trigger: Calling Box.MkdirAll(path) (also reached by moving a document whose target directory does not exist) when the OS mkdir -p fails: permission denied, path component is a file, read-only volume, or illegal characters in a path segment.

Common situations: moveDoc targeting a path where an intermediate segment exists as a file; restoring a notebook onto a read-only disk; long-path limits on Windows exceeding MAX_PATH.

Understand the failure class

Background: mkdir permission denied (EACCES): failed to create directory errors explained — this error's family across 32 libraries.

Related errors


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

Appendix: source

Thrown at kernel/model/box.go:504

		return err
	}
	if err := os.Mkdir(filepath.Join(util.DataDir, box.ID, path), 0755); err != nil {
		msg := fmt.Sprintf(Conf.Language(6), box.Name, path, err)
		logging.LogErrorf("mkdir [path=%s] in box [%s] failed: %s", path, box.ID, err)
		return errors.New(msg)
	}
	IncSync()
	return nil
}

func (box *Box) MkdirAll(path string) error {
	if _, err := box.validateBoxPath(path); err != nil {
		return err
	}
	if err := os.MkdirAll(filepath.Join(util.DataDir, box.ID, path), 0755); err != nil {
		msg := fmt.Sprintf(Conf.Language(6), box.Name, path, err)
		logging.LogErrorf("mkdir all [path=%s] in box [%s] failed: %s", path, box.ID, err)
		return errors.New(msg)
	}
	IncSync()
	return nil
}

func (box *Box) Move(oldPath, newPath string) error {
	if _, err := box.validateBoxPath(oldPath); err != nil {
		return err
	}
	if _, err := box.validateBoxPath(newPath); err != nil {
		return err
	}
	boxLocalPath := filepath.Join(util.DataDir, box.ID)
	fromPath := filepath.Join(boxLocalPath, oldPath)
	toPath := filepath.Join(boxLocalPath, newPath)

	if err := filelock.Rename(fromPath, toPath); err != nil {
		msg := fmt.Sprintf(Conf.Language(5), box.Name, fromPath, err)

View on GitHub (pinned to 9f775e8a12)