flipped-aurora/gin-vue-admin · error

删除前端插件目录失败

Error message

删除前端插件目录失败

What it means

In AutoCodePluginService.Remove, when a plugin is being uninstalled with type 'web' or 'full', os.RemoveAll(webDir) deletes the plugin's frontend directory. If the OS-level removal fails (permissions, file locks, path issues), the underlying error is wrapped with '删除前端插件目录失败' and returned, aborting the uninstall.

Source

Thrown at server/service/system/auto_code_plugin.go:923

	var webDir, serverDir string
	if pluginType == "web" || pluginType == "full" {
		webDir, err = pluginPath(global.GVA_CONFIG.AutoCode.Web, pluginName)
		if err != nil {
			return err
		}
	}
	if pluginType == "server" || pluginType == "full" {
		serverDir, err = pluginPath(global.GVA_CONFIG.AutoCode.Server, pluginName)
		if err != nil {
			return err
		}
	}

	// 1. 删除前端代码
	if pluginType == "web" || pluginType == "full" {
		err = os.RemoveAll(webDir)
		if err != nil {
			return errors.Wrap(err, "删除前端插件目录失败")
		}
	}

	// 2. 删除后端代码
	if pluginType == "server" || pluginType == "full" {
		err = os.RemoveAll(serverDir)
		if err != nil {
			return errors.Wrap(err, "删除后端插件目录失败")
		}

		// 移除注册
		if err = removePluginRegisterImport(pluginName); err != nil {
			return errors.Wrap(err, "移除插件注册失败")
		}
	}

	// 通过utils 获取 api 菜单 字典
	apis, menus, dicts := pluginUtils.GetPluginData(pluginName)

View on GitHub (pinned to 3136500ef3)

Solutions

  1. Close programs locking the directory (IDE, vite dev server) and retry the removal
  2. Check and fix filesystem permissions on web/src/plugin/<pluginName> (chown/chmod)
  3. Verify the frontend path is writable by the server process user
  4. If the directory is already gone, remove it manually and re-run removal, or check err to distinguish NotFound
  5. On Windows, ensure antivirus/indexing is not holding handles during removal

Example fix

// before (permissions issue)
os.RemoveAll(webDir) // permission denied
// after (shell)
sudo chown -R $(whoami) web/src/plugin && retry removal
Defensive patterns

Strategy: validation

Validate before calling

// Go: check writability before calling remove
webDir := filepath.Join("web/src/plugin", pluginName)
if _, err := os.Stat(webDir); err == nil {
    if err := unix.Access(webDir, unix.W_OK); err != nil {
        return fmt.Errorf("web plugin dir not writable: %w", err)
    }
}

Try / catch

// Go: inspect the wrapped error to distinguish not-found vs permission
err := pluginSvc.Remove(ctx, pluginName, "web")
if err != nil && strings.Contains(err.Error(), "删除前端插件目录失败") {
    if os.IsPermission(errors.Unwrap(err)) { /* fix perms or abort */ }
    if errors.Is(errors.Unwrap(err), fs.ErrNotExist) { /* already removed: proceed */ }
}

Prevention

When it happens

Trigger: Calling the plugin removal API (Remove) for a web or full plugin when webDir cannot be deleted: insufficient write permission on web/src/plugin/<name> or its parent, a process (editor, dev server, Windows file lock) holding files open, or a read-only filesystem.

Common situations: Running the server on Windows while Vite/IDE keeps files locked; deploying with a read-only web directory or non-root user lacking ownership; webDir path misconfigured via AutoCode config pointing to a nonexistent or protected location.

Related errors


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