{"record":{"id":"9913ea25bffaf817","repo":"siyuan-note/siyuan","slug":"create-inline-styles-directory-failed-w","errorCode":null,"errorMessage":"create inline styles directory failed: %w","messagePattern":"create inline styles directory failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/inline_style.go","lineNumber":296,"sourceCode":"\tif err != nil {\n\t\treturn nil, false, fmt.Errorf(\"marshal inline styles failed: %w\", err)\n\t}\n\tif maxInlineStylesFileSize < len(data) {\n\t\treturn nil, false, fmt.Errorf(\"inline styles file exceeds the %d byte limit\", maxInlineStylesFileSize)\n\t}\n\n\tdataPath := inlineStylesPath()\n\toldData, readErr := filelock.ReadFile(dataPath)\n\tif readErr != nil && !os.IsNotExist(readErr) {\n\t\treturn nil, false, fmt.Errorf(\"read inline styles failed: %w\", readErr)\n\t}\n\tif bytes.Equal(oldData, data) {\n\t\tcacheWorkspaceAVPalette(ret.AV)\n\t\treturn ret, false, nil\n\t}\n\n\tif err = os.MkdirAll(filepath.Dir(dataPath), 0755); err != nil {\n\t\treturn nil, false, fmt.Errorf(\"create inline styles directory failed: %w\", err)\n\t}\n\tif err = filelock.WriteFile(dataPath, data); err != nil {\n\t\treturn nil, false, fmt.Errorf(\"write inline styles failed: %w\", err)\n\t}\n\tcacheWorkspaceAVPalette(ret.AV)\n\tIncSync()\n\tfor _, avID := range sortedAttributeViewUsageIDs(customColorUsage) {\n\t\tindexes := customColorUsage[avID]\n\t\tif intersectsCustomColorIndexes(indexes, changedCustomColorIndexes) {\n\t\t\tpushReloadAttrView(avID)\n\t\t}\n\t}\n\treturn ret, true, nil\n}\n\nfunc inlineStylesPath() string {\n\treturn filepath.Join(util.DataDir, \"storage\", \"inline-styles.json\")\n}","sourceCodeStart":278,"sourceCodeEnd":314,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/inline_style.go#L278-L314","documentation":"The kernel stores inline styles under a workspace storage subdirectory. If that directory does not exist, it creates it with os.MkdirAll; failure (permissions, read-only filesystem, path conflicts) aborts the write, wrapped as this error.","triggerScenarios":"First palette/styles write in a workspace where the target directory cannot be created — parent directory not writable, path component is a file, or the filesystem is read-only.","commonSituations":"Workspace on a read-only mount or network share; a regular file existing where the directory should be; running the kernel with insufficient OS permissions; antivirus blocking directory creation.","solutions":["Ensure the workspace data/storage parent directories exist, are directories, and are writable by the kernel process user.","Remove or rename any regular file that occupies the target directory path.","Move the workspace off read-only/network mounts or run with sufficient privileges."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Ensure the parent storage directory exists and is writable beforehand:\n// info, err := os.Stat(filepath.Dir(dataPath))\n// writable := err == nil && info.IsDir()","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"create inline styles directory failed\") {\n    // inspect the wrapped cause: fix permissions or remove a blocking file, then retry\n}","preventionTips":["Ensure workspace parent directories are writable by the kernel process user","Do not place regular files where kernel storage directories belong","Keep workspaces off read-only or heavily restricted mounts"],"tags":["filesystem","mkdir","inline-styles"],"backgroundTag":"mkdir-permission-denied","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}