Skip to content

Commit

Permalink
fix(linux): remove support for upgrade
Browse files Browse the repository at this point in the history
resolves #4992 as we are not able to support the upgrade command
on linux as updating oh-my-posh from within itself is impossible
to due a lock on the executable, unlike on darwin

Windows is able to update the executable after we start the installer
in the background and exit the current process
  • Loading branch information
JanDeDobbeleer committed Jun 4, 2024
1 parent 9292763 commit fdf0de0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/cli/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cli

import (
"fmt"
"runtime"

"github.com/jandedobbeleer/oh-my-posh/src/platform"
"github.com/jandedobbeleer/oh-my-posh/src/upgrade"
Expand All @@ -17,6 +18,11 @@ var upgradeCmd = &cobra.Command{
Long: "Upgrade when a new version is available.",
Args: cobra.NoArgs,
Run: func(_ *cobra.Command, _ []string) {
if runtime.GOOS == platform.LINUX {
fmt.Print("\n ⚠️ upgrade is not supported on this platform\n\n")
return
}

if force {
upgrade.Run()
return
Expand Down
2 changes: 2 additions & 0 deletions src/upgrade/cli.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build windows || darwin

package upgrade

import (
Expand Down
2 changes: 0 additions & 2 deletions src/upgrade/cli_unix.go → src/upgrade/cli_darwin.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//go:build !windows

package upgrade

import (
Expand Down
5 changes: 5 additions & 0 deletions src/upgrade/cli_other.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//go:build linux || freebsd || openbsd

package upgrade

func Run() {}

0 comments on commit fdf0de0

Please sign in to comment.