@@ -3,6 +3,7 @@ package cmd
33import (
44 "fmt"
55 "os"
6+ "path/filepath"
67 "sort"
78 "strings"
89
@@ -253,13 +254,18 @@ var pluginUninstallCmd = &cobra.Command{
253254 )
254255
255256 for _ , name := range names {
257+ entry , exists := manifest .Get (name )
258+ if ! exists && ! managedPluginBinaryExists (name ) {
259+ terminal .Warningf ("Plugin %q is not installed; skipping." , name )
260+ continue
261+ }
262+
256263 spinner := uicli .NewSpinner ().
257264 WithStyle (uicli .SpinnerDots ).
258265 WithColor (uicli .CyanColor ).
259266 WithMessage (fmt .Sprintf ("Removing plugin %q..." , name )).
260267 Start ()
261268
262- entry , _ := manifest .Get (name )
263269 inst , err := installer .FromManifest (entry )
264270 if err != nil {
265271 // If we can't determine the installer type, just remove the binary directly.
@@ -490,6 +496,20 @@ func uniquePluginNames(args []string) []string {
490496 return names
491497}
492498
499+ func managedPluginBinaryExists (name string ) bool {
500+ dir , err := plugin .PluginBinDir ()
501+ if err != nil {
502+ return false
503+ }
504+
505+ path := filepath .Join (dir , plugin .BinPrefix + name )
506+ info , err := os .Stat (path )
507+ if err != nil {
508+ return false
509+ }
510+ return ! info .IsDir ()
511+ }
512+
493513func ensureInstallNameAvailable (manifest * plugin.Manifest , name string ) error {
494514 if _ , exists := manifest .Get (name ); exists {
495515 return fmt .Errorf ("plugin %q already exists; use \" clime plugin update %s\" or uninstall it first" , name , name )
0 commit comments