pulumi/pulumi · error

failed to delete %s plugin %s: %w

Error message

failed to delete %s plugin %s: %w

What it means

When deleting matched plugins, each `plugin.Delete()` failure is collected into a multierror and reported as "failed to delete <kind> plugin <name>: <cause>". Other matching plugins are still attempted; accumulated errors are returned at the end.

Source

Thrown at pkg/cmd/pulumi/plugin/plugin_remove.go:131

					opts.Color.Colorize(
						fmt.Sprintf("%sThis will remove %d plugin%s from the cache:%s\n",
							colors.SpecAttention, len(deletes), suffix, colors.Reset)))
				for _, del := range deletes {
					fmt.Fprintf(out, "    %s %s\n", del.Kind, del.String())
				}
				if !ui.ConfirmPrompt("", "yes", opts) {
					return nil
				}
			}

			// Run the actual delete operations.
			var result error
			for _, plugin := range deletes {
				if err := plugin.Delete(); err == nil {
					fmt.Fprintf(out, "removed: %s %v\n", plugin.Kind, plugin)
				} else {
					result = multierror.Append(
						result, fmt.Errorf("failed to delete %s plugin %s: %w", plugin.Kind, plugin, err))
				}
			}
			return result
		},
	}

	constrictor.AttachArguments(cmd, &constrictor.Arguments{
		Arguments: []constrictor.Argument{
			{Name: "kind"},
			{Name: "name"},
			{Name: "version"},
		},
		Required: 0,
		Variadic: false,
	})

	cmd.PersistentFlags().BoolVarP(
		&all, "all", "a", false,

View on GitHub (pinned to 793f7b2e16)

Solutions

  1. Stop any running pulumi processes that may hold the plugin open, then re-run removal
  2. Fix or take ownership of the plugin directory under ~/.pulumi/plugins
  3. Delete the plugin directory manually if Pulumi's deleter keeps failing

Example fix

// before (file in use)
pulumi plugin rm resource aws 5.0.0
// after
taskkill /IM pulumi.exe /F & pulumi plugin rm resource aws 5.0.0
Defensive patterns

Strategy: retry

Validate before calling

ensureNoRunningPulumiProcesses(); ensureWritable(pluginDir)

Try / catch

if err := runCmd("pulumi", "plugin", "rm", ...); err != nil && strings.Contains(err.Error(), "failed to delete") { time.Sleep(2*time.Second); retry() }

Prevention

When it happens

Trigger: `pulumi plugin rm` matching plugins whose files cannot be removed: files in use on Windows, permission denied on plugin directories, or the directory vanishing mid-delete.

Common situations: A running engine or language host still holds the plugin binary open (Windows); plugin dir owned by root or another user; antivirus locking files.

Related errors


AI-assisted analysis of pulumi/pulumi@793f7b2e16 (2026-08-31). Data as JSON: /api/errors/03ade8258137f4f3. Report an issue: GitHub.