{"record":{"id":"0a738c489fb3a09d","repo":"siyuan-note/siyuan","slug":"appearance-files-not-found-at-s","errorCode":null,"errorMessage":"appearance files not found at [%s]","messagePattern":"appearance files not found at \\[(.+?)\\]","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"kernel/cli/cmd/root.go","lineNumber":75,"sourceCode":"\t\tsql.FlushQueue()\n\t\treturn nil\n\t},\n\tPersistentPreRunE: func(cmd *cobra.Command, args []string) error {\n\t\t// workspace 子命令不需要工作空间校验\n\t\tif cmd.Parent() != nil && cmd.Parent().Name() == \"workspace\" {\n\t\t\treturn nil\n\t\t}\n\n\t\t// 默认工作目录取内核可执行文件所在目录的上一级（打包后的 resources/，appearance/、stage/ 所在目录），\n\t\t// 而非内核可执行文件所在目录本身（resources/kernel/）。resolveWorkingDir() 会校验 appearance/langs 实际存在，\n\t\t// 兼容开发态等多种目录布局。\n\t\tif workingDir := resolveWorkingDir(); workingDir != \"\" {\n\t\t\tutil.WorkingDir = workingDir\n\t\t}\n\n\t\tlangsDir := filepath.Join(util.WorkingDir, \"appearance\", \"langs\")\n\t\tif _, err := os.Stat(langsDir); os.IsNotExist(err) {\n\t\t\treturn fmt.Errorf(\"appearance files not found at [%s]\", langsDir)\n\t\t}\n\n\t\t// 设置工作空间路径\n\t\tif workspacePath == \"\" {\n\t\t\tworkspacePath = os.Getenv(\"SIYUAN_WORKSPACE_PATH\")\n\t\t}\n\t\tif workspacePath == \"\" {\n\t\t\tworkspacePath = filepath.Join(util.HomeDir, \"SiYuan\")\n\t\t}\n\n\t\tif _, err := os.Stat(workspacePath); os.IsNotExist(err) {\n\t\t\treturn fmt.Errorf(\"directory not found: %s\", workspacePath)\n\t\t}\n\t\tif !util.IsWorkspaceDir(workspacePath) {\n\t\t\treturn fmt.Errorf(\"not a valid workspace: %s\", workspacePath)\n\t\t}\n\n\t\tutil.Mode = \"prod\"","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/cli/cmd/root.go#L57-L93","documentation":"Thrown in `rootCmd.PersistentPreRunE` when `appearance/langs` does not exist under the resolved working directory. The working dir is resolved by `resolveWorkingDir()`, which probes candidate directories relative to the kernel executable (e.g. `resources/`, `app/`). If none contains `appearance/langs`, the resolved dir is empty and `util.WorkingDir` stays at its build-time default, so the langs stat fails. This guards every CLI subcommand except `workspace`, because the kernel cannot initialize i18n/UI assets without the langs directory.","triggerScenarios":"Running the kernel binary from an unpackaged or relocated location where `appearance/langs/` is not a sibling/parent of the executable; running a raw `go run`/built binary outside the repo layout; a broken install where `resources/` was not extracted; symlinks that defeat `resolveWorkingDir`'s candidate paths.","commonSituations":"Development builds invoked from a directory not covered by the four candidate probes (`exeDir/..`, `exeDir/../app`, `exeDir/app`, `exeDir/../../app`, plus macOS `Resources`); moving the kernel binary out of its `resources/kernel/` folder; partial extraction of a release archive that omitted `appearance/`.","solutions":["Run the kernel binary from its installed location (inside `resources/kernel/` for releases) so `resolveWorkingDir` finds `../appearance/langs`.","For development, ensure `app/appearance/langs` exists and invoke the binary from a path where one of the candidate probes reaches `app/` (e.g. build output under `kernel/`).","Verify the install: check that `<installDir>/appearance/langs/en.json` exists; re-extract the release archive if it is missing.","On macOS, confirm the `.app` bundle's `Contents/Resources/appearance/langs` is present."],"exampleFix":"// before: invoked from /tmp after copying the binary out\n/tmp/SiYuan-Kernel search foo\n// after: run from the bundled resources layout\n/opt/siyuan/resources/kernel/SiYuan-Kernel search foo","handlingStrategy":"validation","validationCode":"// Verify appearance/langs exists under the install root before invoking the kernel.\nlangsDir := filepath.Join(installDir, \"appearance\", \"langs\")\nif fi, err := os.Stat(langsDir); err != nil || !fi.IsDir() {\n    log.Fatalf(\"appearance/langs missing under %s; reinstall or run from the bundled resources dir\", installDir)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run the kernel binary from its installed `resources/kernel/` location so `resolveWorkingDir` succeeds.","For development, build/run from a path where `app/appearance/langs` is reachable by the candidate probes.","After extracting a release, verify `appearance/langs/en.json` exists before first run.","Do not relocate the kernel binary out of its resources folder."],"tags":["cli","bootstrap","workspace","appearance","i18n","install"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}