{"record":{"id":"280c8c6788c8ab65","repo":"flipped-aurora/gin-vue-admin","slug":"service","errorCode":null,"errorMessage":"读取service文件夹失败!","messagePattern":"读取service文件夹失败!","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/service/system/auto_code_package.go","lineNumber":142,"sourceCode":"\t}\n\terr := global.GVA_DB.WithContext(ctx).Where(\"package_name IN ?\", names).Delete(&model.SysAutoCodePackage{}).Error\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"删除失败!\")\n\t}\n\treturn nil\n}\n\n// All 获取所有包\n// @author: [piexlmax](https://github.com/piexlmax)\n// @author: [SliverHorn](https://github.com/SliverHorn)\nfunc (s *autoCodePackage) All(ctx context.Context) (entities []model.SysAutoCodePackage, err error) {\n\tserver := make([]model.SysAutoCodePackage, 0)\n\tplugin := make([]model.SysAutoCodePackage, 0)\n\tserverPath := filepath.Join(global.GVA_CONFIG.AutoCode.Root, global.GVA_CONFIG.AutoCode.Server, \"service\")\n\tpluginPath := filepath.Join(global.GVA_CONFIG.AutoCode.Root, global.GVA_CONFIG.AutoCode.Server, \"plugin\")\n\tserverDir, err := os.ReadDir(serverPath)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"读取service文件夹失败!\")\n\t}\n\tpluginDir, err := os.ReadDir(pluginPath)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"读取plugin文件夹失败!\")\n\t}\n\tfor i := 0; i < len(serverDir); i++ {\n\t\tif serverDir[i].IsDir() {\n\t\t\tserverPackage := model.SysAutoCodePackage{\n\t\t\t\tPackageName: serverDir[i].Name(),\n\t\t\t\tTemplate:    \"package\",\n\t\t\t\tLabel:       serverDir[i].Name() + \"包\",\n\t\t\t\tDesc:        \"系统自动读取\" + serverDir[i].Name() + \"包\",\n\t\t\t\tModule:      global.GVA_CONFIG.AutoCode.Module,\n\t\t\t}\n\t\t\tserver = append(server, serverPackage)\n\t\t}\n\t}\n\tfor i := 0; i < len(pluginDir); i++ {","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/service/system/auto_code_package.go#L124-L160","documentation":"The All method scans the filesystem under AutoCode.Root/Server to discover packages as directories, treating 'service' and 'plugin' as package sources. This error wraps a failure of os.ReadDir on the service directory, meaning the path could not be read (missing or permission).","triggerScenarios":"Calling autoCodePackage.All when filepath.Join(AutoCode.Root, AutoCode.Server, \"service\") does not exist or is unreadable — typically misconfigured AutoCode.Root/AutoCode.Server in config, or the project layout was moved.","commonSituations":"Running the backend from a different working directory so relative Root config resolves wrong; AutoCode.Server left at default while repo is checked out elsewhere; renamed/moved service directory in a customized repo.","solutions":["Verify config.yaml auto-code root/server values match the actual server source location","Create the missing service directory or fix the path so <root>/<server>/service exists","Ensure the process user has read permission on that directory","Run the server from the expected working directory if Root is relative"],"exampleFix":"# before (config.yaml)\nauto-code:\n  root: ./old-path\n# after\nauto-code:\n  root: /path/to/project","handlingStrategy":"validation","validationCode":"serverPath := filepath.Join(global.GVA_CONFIG.AutoCode.Root, global.GVA_CONFIG.AutoCode.Server, \"service\")\nif info, err := os.Stat(serverPath); err != nil {\n    return fmt.Errorf(\"service dir missing: %s\", serverPath)\n} else if !info.IsDir() {\n    return fmt.Errorf(\"%s is not a directory\", serverPath)\n}\nif file, err := os.Open(serverPath); err != nil {\n    return fmt.Errorf(\"service dir unreadable: %w\", err)\n} else {\n    file.Close()\n}","typeGuard":null,"tryCatchPattern":"serverDir, err := os.ReadDir(serverPath)\nif err != nil {\n    if os.IsNotExist(err) {\n        return nil, fmt.Errorf(\"service dir %s not found; check auto-code config\", serverPath)\n    }\n    return nil, errors.Wrap(err, \"读取service文件夹失败!\")\n}","preventionTips":["Keep AutoCode.Root/AutoCode.Server in config.yaml pointing at the real server tree","Start the server from the intended working directory if paths are relative","Create standard directories (service, plugin) in deployment scripts","Add startup validation that required codegen directories exist"],"tags":["filesystem","directory-not-found","config","codegen"],"backgroundTag":"directory-not-found","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}