siyuan-note/siyuan · error
mkdir master password migration dir failed: %w
Error message
mkdir master password migration dir failed: %w
What it means
writeMasterPasswordMigrationUnlocked could not create the directory holding the master password migration state file. The migration record (unlocked box material) cannot be persisted, so the migration step aborts with this wrapped OS error.
Source
Thrown at kernel/model/crypto.go:540
NewWrappedDEK []byte `json:"newWrappedDEK"`
NewWrapNonce []byte `json:"newWrapNonce"`
Metadata []byte `json:"metadata"`
}
func masterPasswordMigrationPath() string {
return filepath.Join(util.DataDir, ".siyuan", "master-password-migration.json")
}
func writeMasterPasswordMigration(m *masterPasswordMigration) error {
masterPasswordMigrationMu.Lock()
defer masterPasswordMigrationMu.Unlock()
return writeMasterPasswordMigrationUnlocked(m)
}
func writeMasterPasswordMigrationUnlocked(m *masterPasswordMigration) error {
p := masterPasswordMigrationPath()
if err := os.MkdirAll(filepath.Dir(p), 0755); err != nil {
return fmt.Errorf("mkdir master password migration dir failed: %w", err)
}
data, err := gulu.JSON.MarshalIndentJSON(m, "", " ")
if err != nil {
return fmt.Errorf("marshal master password migration failed: %w", err)
}
return filelock.WriteFile(p, data)
}
func readMasterPasswordMigration() (*masterPasswordMigration, error) {
masterPasswordMigrationMu.Lock()
defer masterPasswordMigrationMu.Unlock()
return readMasterPasswordMigrationUnlocked()
}
func readMasterPasswordMigrationUnlocked() (*masterPasswordMigration, error) {
p := masterPasswordMigrationPath()
if !filelock.IsExist(p) {
return nil, nilView on GitHub (pinned to 8641553a1f)
Solutions
- Grant the kernel process write permission on the workspace data directory
- Remove any regular file occupying the migration directory path
- Free disk space or remount read-write
- Verify masterPasswordMigrationPath() points inside the active workspace
Example fix
// before: data dir not writable ls -ld ~/SiYuan/data # root-owned // after sudo chown -R $USER ~/SiYuan/data err := writeMasterPasswordMigration(m) // succeeds
Defensive patterns
Strategy: try-catch
Validate before calling
if err := os.MkdirAll(filepath.Dir(masterPasswordMigrationPath()), 0755); err != nil {
return fmt.Errorf("migration dir not creatable: %w", err)
} Try / catch
if err := writeMasterPasswordMigration(m); err != nil {
if os.IsPermission(errors.Unwrap(err)) {
// instruct user to fix workspace data directory ownership
}
return err
} Prevention
- Ensure the kernel process owns the workspace data directory
- Avoid running multiple SiYuan instances against one workspace
- Keep the workspace off read-only mounts and synced/locked folders
- Precreate the data directory structure with correct permissions during deployment
When it happens
Trigger: writeMasterPasswordMigration or removeMasterPasswordMigrationBox calls writeMasterPasswordMigrationUnlocked; os.MkdirAll(filepath.Dir(masterPasswordMigrationPath()), 0755) fails due to permissions, read-only FS, or a non-directory in the path.
Common situations: Workspace data directory with wrong ownership, read-only mount, full disk, or a stray file occupying the migration directory 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
- read master password migration failed: %w
- create inline styles directory failed: %w
- create dir for publishAccess.json [%s] failed: %s
- create import dir failed:
- read destination [%s] failed: %w
AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11).
Data as JSON: /api/errors/c24a9171cd1a7cf9.
Report an issue: GitHub.