From dc2cb7f0cd05fcab262b7ddb2c2373b974155e78 Mon Sep 17 00:00:00 2001 From: "Christian Weichel (Chris)" Date: Wed, 22 Nov 2023 20:36:15 +0000 Subject: [PATCH] Improve selfupdate support when binary cannot be written by the executing user --- components/local-app/pkg/selfupdate/selfupdate.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/components/local-app/pkg/selfupdate/selfupdate.go b/components/local-app/pkg/selfupdate/selfupdate.go index 992c399a30d6be..13cbac0879a2e5 100644 --- a/components/local-app/pkg/selfupdate/selfupdate.go +++ b/components/local-app/pkg/selfupdate/selfupdate.go @@ -207,11 +207,18 @@ func ReplaceSelf(ctx context.Context, manifest *Manifest) error { defer resp.Body.Close() dgst, _ := hex.DecodeString(binary.Digest.Hex()) - return update.Apply(resp.Body, update.Options{ + err = update.Apply(resp.Body, update.Options{ Checksum: dgst, Hash: crypto.SHA256, TargetMode: 0755, }) + if err != nil && strings.Contains(err.Error(), "permission denied") && runtime.GOOS != "windows" { + cfgfn := config.FromContext(ctx).Filename + err = prettyprint.AddResolution(err, + fmt.Sprintf("run `sudo {gitpod} --config %s version update`", cfgfn), + ) + } + return err } var ErrNoBinaryAvailable = errors.New("no binary available for this platform")