Skip to content

Commit

Permalink
Improve selfupdate support
Browse files Browse the repository at this point in the history
when binary cannot be written by the executing user
  • Loading branch information
csweichel committed Nov 22, 2023
1 parent 79666cd commit dc2cb7f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion components/local-app/pkg/selfupdate/selfupdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit dc2cb7f

Please sign in to comment.