Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit 6371084

Browse files
committed
internal/cmd/update.go: use os.Executable() instead of os.Args[0]
1 parent f6ce76f commit 6371084

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

internal/cmd/update.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,14 @@ func updateCmd() *cobra.Command {
5656
Timeout: 10 * time.Second,
5757
}
5858

59+
currExe, err := os.Executable()
60+
if err != nil {
61+
return clog.Fatal("init: get current executable", clog.Causef(err.Error()))
62+
}
63+
5964
updater := &updater{
6065
confirmF: defaultConfirm,
61-
executablePath: os.Args[0],
66+
executablePath: currExe,
6267
httpClient: httpClient,
6368
fs: afero.NewOsFs(),
6469
osF: func() string { return runtime.GOOS },
@@ -85,7 +90,7 @@ func (u *updater) Run(ctx context.Context, force bool, coderURLString string) er
8590

8691
currentBinaryStat, err := u.fs.Stat(u.executablePath)
8792
if err != nil {
88-
return clog.Fatal("preflight: cannot stat current binary", clog.Causef("%s", err))
93+
return clog.Fatal("preflight: cannot stat current binary", clog.Causef(err.Error()))
8994
}
9095

9196
if currentBinaryStat.Mode().Perm()&0222 == 0 {

0 commit comments

Comments
 (0)