flipped-aurora/gin-vue-admin · error

读取plugin文件夹失败!

Error message

读取plugin文件夹失败!

What it means

Same filesystem-scan logic as the service scan, but for the plugin directory: All calls os.ReadDir on <AutoCode.Root>/<AutoCode.Server>/plugin and wraps any failure with this message. It indicates the plugin directory cannot be read.

Source

Thrown at server/service/system/auto_code_package.go:146

	}
	return nil
}

// All 获取所有包
// @author: [piexlmax](https://github.com/piexlmax)
// @author: [SliverHorn](https://github.com/SliverHorn)
func (s *autoCodePackage) All(ctx context.Context) (entities []model.SysAutoCodePackage, err error) {
	server := make([]model.SysAutoCodePackage, 0)
	plugin := make([]model.SysAutoCodePackage, 0)
	serverPath := filepath.Join(global.GVA_CONFIG.AutoCode.Root, global.GVA_CONFIG.AutoCode.Server, "service")
	pluginPath := filepath.Join(global.GVA_CONFIG.AutoCode.Root, global.GVA_CONFIG.AutoCode.Server, "plugin")
	serverDir, err := os.ReadDir(serverPath)
	if err != nil {
		return nil, errors.Wrap(err, "读取service文件夹失败!")
	}
	pluginDir, err := os.ReadDir(pluginPath)
	if err != nil {
		return nil, errors.Wrap(err, "读取plugin文件夹失败!")
	}
	for i := 0; i < len(serverDir); i++ {
		if serverDir[i].IsDir() {
			serverPackage := model.SysAutoCodePackage{
				PackageName: serverDir[i].Name(),
				Template:    "package",
				Label:       serverDir[i].Name() + "包",
				Desc:        "系统自动读取" + serverDir[i].Name() + "包",
				Module:      global.GVA_CONFIG.AutoCode.Module,
			}
			server = append(server, serverPackage)
		}
	}
	for i := 0; i < len(pluginDir); i++ {
		if pluginDir[i].IsDir() {
			dirNameMap := map[string]bool{
				"api":        true,
				"config":     true,

View on GitHub (pinned to 3136500ef3)

Solutions

  1. Create the missing server/plugin directory (an empty one satisfies the scan)
  2. Fix AutoCode.Root/AutoCode.Server in config.yaml to point at the real server tree
  3. Check directory read permissions for the running user
  4. Guard the scan with os.Stat before ReadDir if plugin may legitimately be absent

Example fix

// before: hard failure when plugin dir missing
pluginDir, err := os.ReadDir(pluginPath)
if err != nil {
    return nil, errors.Wrap(err, "读取plugin文件夹失败!")
}
// after: tolerate absence
if _, statErr := os.Stat(pluginPath); os.IsNotExist(statErr) {
    pluginDir = []os.DirEntry{}
} else if pluginDir, err = os.ReadDir(pluginPath); err != nil {
    return nil, errors.Wrap(err, "读取plugin文件夹失败!")
}
Defensive patterns

Strategy: validation

Validate before calling

pluginPath := filepath.Join(global.GVA_CONFIG.AutoCode.Root, global.GVA_CONFIG.AutoCode.Server, "plugin")
if info, err := os.Stat(pluginPath); err != nil || !info.IsDir() {
    return fmt.Errorf("plugin dir missing at %s", pluginPath)
}

Try / catch

pluginDir, err := os.ReadDir(pluginPath)
if err != nil {
    if os.IsNotExist(err) {
        pluginDir = []os.DirEntry{}
    } else {
        return nil, errors.Wrap(err, "读取plugin文件夹失败!")
    }
}

Prevention

When it happens

Trigger: Calling autoCodePackage.All when the plugin directory under the configured server root does not exist or is not readable — no plugin directory was ever created in this checkout, or Root/Server config is wrong.

Common situations: Fresh/trimmed checkout where server/plugin was never created; customized repo that dropped the plugin folder; misconfigured auto-code root in config.yaml.

Related errors


AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31). Data as JSON: /api/errors/0c6655fc7157ef96. Report an issue: GitHub.