diff --git a/Makefile b/Makefile index de3f72d15ff..01be808fc80 100644 --- a/Makefile +++ b/Makefile @@ -86,7 +86,6 @@ update: notice clean: mage @rm -rf build @$(foreach var,$(PROJECTS) $(PROJECTS_XPACK_MAGE),$(MAKE) -C $(var) clean || exit 1;) - @$(MAKE) -C generator clean @-mage -clean ## check : TBD. diff --git a/dev-tools/mage/clean.go b/dev-tools/mage/clean.go index 9f191973eb3..c58a7b56ab0 100644 --- a/dev-tools/mage/clean.go +++ b/dev-tools/mage/clean.go @@ -18,6 +18,11 @@ package mage import ( + "errors" + "fmt" + "os" + "strings" + "github.com/magefile/mage/sh" ) @@ -46,6 +51,12 @@ func Clean(pathLists ...[]string) error { for _, f := range paths { f = MustExpand(f) if err := sh.Rm(f); err != nil { + if errors.Is(err, os.ErrPermission) || + strings.Contains(err.Error(), "permission denied") { + fmt.Printf("warn: cannot delete %q: %v, proceeding anyway\n", + f, err) + continue + } return err } }