JanDeDobbeleer / oh-my-posh

The most customisable and low-latency cross platform/shell prompt renderer
https://ohmyposh.dev
MIT License
17.37k stars 2.39k forks source link

UI was broken after "brew upgrade" #3030

Closed ras0q closed 2 years ago

ras0q commented 2 years ago

Code of Conduct

What happened?

I install omp with brew.

After running brew upgrade, the following log was output and UI was broken.

==> Upgrading oh-my-posh
  12.7.1 -> 12.10.0 

==> Pouring oh-my-posh--12.10.0.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/oh-my-posh/12.10.0: 130 files, 19.8MB
==> Running `brew cleanup oh-my-posh`...
Removing: /home/linuxbrew/.linuxbrew/Cellar/oh-my-posh/12.7.1... (130 files, 19.8MB)
Removing: /home/ras/.cache/Homebrew/oh-my-posh--12.7.1... (8.1MB)

...

/home/linuxbrew/.linuxbrew/Cellar/oh-my-posh/12.7.1/bin/oh-my-posh: command not found
- (line 37): 
    /home/linuxbrew/.linuxbrew/Cellar/oh-my-posh/12.7.1/bin/oh-my-posh print primary --config $POSH_THEME --shell fish --error $omp_status_cache --execution-time $omp_duration --stack-count $omp_stack_count --shell-version $FISH_VERSION
    ^
in function 'fish_prompt'
in command substitution
/home/linuxbrew/.linuxbrew/Cellar/oh-my-posh/12.7.1/bin/oh-my-posh: command not found
- (line 54): 
    /home/linuxbrew/.linuxbrew/Cellar/oh-my-posh/12.7.1/bin/oh-my-posh print right --config $POSH_THEME --shell fish --error $omp_status_cache --execution-time $omp_duration --stack-count $omp_stack_count --shell-version $FISH_VERSION
    ^
in function 'fish_right_prompt'
in command substitution

Theme

jblab_2021

What OS are you seeing the problem on?

Linux

Which shell are you using?

fish

Log output

oh-my-posh debug

Version: 12.10.0

Segments:

ConsoleTitle(true)   -   1 ms - dotfiles
os(true)             -   0 ms -   
root(false)          -   0 ms - 
path(true)           -   1 ms -      dotfiles 
git(true)            -   5 ms -   main  ~2  2 
time(true)           -   0 ms -  17:42 
executiontime(true)  -   0 ms -  0s 
exit(false)          -   0 ms - 
exit(true)           -   2 ms - $

Run duration: 13.918099ms

Cache path: /home/ras/.cache/oh-my-posh

Config path: /home/ras/.omp-theme.json

Logs:

2022/10/31 17:42:04 debug: Getenv

2022/10/31 17:42:04 Getenv duration: 16.2µs, args: XDG_CACHE_HOME
2022/10/31 17:42:04 CachePath duration: 47.3µs, args: 
2022/10/31 17:42:04 debug: Getenv
/home/ras/.omp-theme.json
2022/10/31 17:42:04 Getenv duration: 4.2µs, args: POSH_THEME
2022/10/31 17:42:04 resolveConfigPath duration: 18µs, args: 
2022/10/31 17:42:04 Init duration: 515.499µs, args: 
2022/10/31 17:42:04 Flags duration: 100ns, args: 
2022/10/31 17:42:04 config.loadConfig duration: 905.8µs, args: 
2022/10/31 17:42:04 Flags duration: 100ns, args: 
2022/10/31 17:42:04 debug: Getenv

2022/10/31 17:42:04 Getenv duration: 1.6µs, args: OMP_CACHE_DISABLED
2022/10/31 17:42:04 Root duration: 2µs, args: 
2022/10/31 17:42:04 debug: Shell
process name: fish
2022/10/31 17:42:04 Shell duration: 768.3µs, args: 
2022/10/31 17:42:04 ErrorCode duration: 100ns, args: 
2022/10/31 17:42:04 debug: Getenv
Ubuntu
2022/10/31 17:42:04 Getenv duration: 2.4µs, args: WSL_DISTRO_NAME
2022/10/31 17:42:04 IsWsl duration: 6.2µs, args: 
2022/10/31 17:42:04 GOOS duration: 200ns, args: 
2022/10/31 17:42:04 debug: Pwd
/home/ras/ghq/github.com/Ras96/dotfiles
2022/10/31 17:42:04 Pwd duration: 12.6µs, args: 
2022/10/31 17:42:04 GOOS duration: 100ns, args: 
2022/10/31 17:42:04 GOOS duration: 0s, args: 
2022/10/31 17:42:04 GOOS duration: 0s, args: 
2022/10/31 17:42:04 GOOS duration: 100ns, args: 
2022/10/31 17:42:04 GOOS duration: 100ns, args: 
2022/10/31 17:42:04 GOOS duration: 0s, args: 
2022/10/31 17:42:04 GOOS duration: 0s, args: 
2022/10/31 17:42:04 GOOS duration: 100ns, args: 
2022/10/31 17:42:04 GOOS duration: 0s, args: 
2022/10/31 17:42:04 GOOS duration: 0s, args: 
2022/10/31 17:42:04 debug: User
ras
2022/10/31 17:42:04 User duration: 1.4µs, args: 
2022/10/31 17:42:04 debug: Host
asymp
2022/10/31 17:42:04 Host duration: 24.8µs, args: 
2022/10/31 17:42:04 GOOS duration: 100ns, args: 
2022/10/31 17:42:04 TemplateCache duration: 908.7µs, args: 
2022/10/31 17:42:04 Flags duration: 100ns, args: 
2022/10/31 17:42:04 debug: Pwd
/home/ras/ghq/github.com/Ras96/dotfiles
2022/10/31 17:42:04 Pwd duration: 3.3µs, args: 
2022/10/31 17:42:04 GOOS duration: 0s, args: 
2022/10/31 17:42:04 GOOS duration: 0s, args: 
2022/10/31 17:42:04 TemplateCache duration: 100ns, args: 
2022/10/31 17:42:04 TemplateCache duration: 300ns, args: 
2022/10/31 17:42:04 Shell duration: 0s, args: 
2022/10/31 17:42:04 debug: Pwd
/home/ras/ghq/github.com/Ras96/dotfiles
2022/10/31 17:42:04 Pwd duration: 3.1µs, args: 
2022/10/31 17:42:04 GOOS duration: 100ns, args: 
2022/10/31 17:42:04 Root duration: 800ns, args: 
2022/10/31 17:42:04 debug: Pwd
/home/ras/ghq/github.com/Ras96/dotfiles
2022/10/31 17:42:04 Pwd duration: 4.3µs, args: 
2022/10/31 17:42:04 GOOS duration: 200ns, args: 
2022/10/31 17:42:04 debug: Pwd
/home/ras/ghq/github.com/Ras96/dotfiles
2022/10/31 17:42:04 Pwd duration: 1.3µs, args: 
2022/10/31 17:42:04 Shell duration: 100ns, args: 
2022/10/31 17:42:04 Shell duration: 1.2µs, args: 
2022/10/31 17:42:04 GOOS duration: 0s, args: 
2022/10/31 17:42:04 PathSeparator duration: 100ns, args: 
2022/10/31 17:42:04 GOOS duration: 100ns, args: 
2022/10/31 17:42:04 GOOS duration: 0s, args: 
2022/10/31 17:42:04 GOOS duration: 200ns, args: 
2022/10/31 17:42:04 GOOS duration: 0s, args: 
2022/10/31 17:42:04 PathSeparator duration: 100ns, args: 
2022/10/31 17:42:04 PathSeparator duration: 0s, args: 
2022/10/31 17:42:04 GOOS duration: 100ns, args: 
2022/10/31 17:42:04 GOOS duration: 100ns, args: 
2022/10/31 17:42:04 PathSeparator duration: 0s, args: 
2022/10/31 17:42:04 GOOS duration: 100ns, args: 
2022/10/31 17:42:04 GOOS duration: 0s, args: 
2022/10/31 17:42:04 PathSeparator duration: 0s, args: 
2022/10/31 17:42:04 GOOS duration: 0s, args: 
2022/10/31 17:42:04 GOOS duration: 100ns, args: 
2022/10/31 17:42:04 PathSeparator duration: 0s, args: 
2022/10/31 17:42:04 PathSeparator duration: 0s, args: 
2022/10/31 17:42:04 PathSeparator duration: 100ns, args: 
2022/10/31 17:42:04 PathSeparator duration: 0s, args: 
2022/10/31 17:42:04 PathSeparator duration: 100ns, args: 
2022/10/31 17:42:04 debug: Pwd
/home/ras/ghq/github.com/Ras96/dotfiles
2022/10/31 17:42:04 Pwd duration: 14.2µs, args: 
2022/10/31 17:42:04 debug: Getenv
Ubuntu
2022/10/31 17:42:04 Getenv duration: 2.1µs, args: WSL_DISTRO_NAME
2022/10/31 17:42:04 IsWsl duration: 5µs, args: 
2022/10/31 17:42:04 debug: RunCommand
//wsl.localhost/Ubuntu/home/ras/ghq/github.com/Ras96/dotfiles
2022/10/31 17:42:04 RunCommand duration: 1.0143ms, args: wslpath -m /home/ras/ghq/github.com/Ras96/dotfiles
2022/10/31 17:42:04 StackCount duration: 100ns, args: 
2022/10/31 17:42:04 DirIsWritable duration: 9.8µs, args: /home/ras/ghq/github.com/Ras96/dotfiles
2022/10/31 17:42:04 TemplateCache duration: 200ns, args: 
2022/10/31 17:42:04 TemplateCache duration: 300ns, args: 
2022/10/31 17:42:04 Shell duration: 500ns, args: 
2022/10/31 17:42:04 debug: Pwd
/home/ras/ghq/github.com/Ras96/dotfiles
2022/10/31 17:42:04 Pwd duration: 2.5µs, args: 
2022/10/31 17:42:04 GOOS duration: 100ns, args: 
2022/10/31 17:42:04 debug: Getenv
Ubuntu
2022/10/31 17:42:04 Getenv duration: 1.2µs, args: WSL_DISTRO_NAME
2022/10/31 17:42:04 IsWsl duration: 3.1µs, args: 
2022/10/31 17:42:04 debug: FileContent
5.15.68.1-microsoft-standard-WSL2

2022/10/31 17:42:04 FileContent duration: 55µs, args: /proc/sys/kernel/osrelease
2022/10/31 17:42:04 IsWsl2 duration: 94.5µs, args: 
2022/10/31 17:42:04 debug: Pwd
/home/ras/ghq/github.com/Ras96/dotfiles
2022/10/31 17:42:04 Pwd duration: 2.1µs, args: 
2022/10/31 17:42:04 debug: RunCommand
//wsl.localhost/Ubuntu/home/ras/ghq/github.com/Ras96/dotfiles
2022/10/31 17:42:04 RunCommand duration: 1.1021ms, args: wslpath -m /home/ras/ghq/github.com/Ras96/dotfiles
2022/10/31 17:42:04 GOOS duration: 0s, args: 
2022/10/31 17:42:04 debug: CommandPath
/usr/bin/git
2022/10/31 17:42:04 CommandPath duration: 74.4µs, args: git
2022/10/31 17:42:04 HasCommand duration: 77.2µs, args: git
2022/10/31 17:42:04 debug: Pwd
/home/ras/ghq/github.com/Ras96/dotfiles
2022/10/31 17:42:04 Pwd duration: 1µs, args: 
2022/10/31 17:42:04 HasParentFilePath duration: 5.2µs, args: .git
2022/10/31 17:42:04 GOOS duration: 100ns, args: 
2022/10/31 17:42:04 GOOS duration: 0s, args: 
2022/10/31 17:42:04 GOOS duration: 0s, args: 
2022/10/31 17:42:04 GOOS duration: 100ns, args: 
2022/10/31 17:42:04 GOOS duration: 100ns, args: 
2022/10/31 17:42:04 GOOS duration: 0s, args: 
2022/10/31 17:42:04 GOOS duration: 0s, args: 
2022/10/31 17:42:04 GOOS duration: 0s, args: 
2022/10/31 17:42:04 GOOS duration: 100ns, args: 
2022/10/31 17:42:04 GOOS duration: 0s, args: 
2022/10/31 17:42:04 GOOS duration: 100ns, args: 
2022/10/31 17:42:04 debug: Getenv

2022/10/31 17:42:04 Getenv duration: 1.9µs, args: POSH_GIT_STATUS
2022/10/31 17:42:04 debug: RunCommand
# branch.oid 3b8cbd39e7619d084840ed71ad6170a89c9b2829
# branch.head main
# branch.upstream origin/main
# branch.ab +0 -0
1 .M N... 100644 100644 100644 bd3763496a197808ea71422bad979bb64e90af2a bd3763496a197808ea71422bad979bb64e90af2a Makefile
1 .M N... 100644 100644 100644 42bc164f74cc5937699f5037c10bae79169500ee 42bc164f74cc5937699f5037c10bae79169500ee common/.Brewfile.lock.json
2022/10/31 17:42:04 RunCommand duration: 2.9893ms, args: git -C /home/ras/ghq/github.com/Ras96/dotfiles --no-optional-locks -c core.quotepath=false -c color.status=false status -unormal --branch --porcelain=2
2022/10/31 17:42:04 debug: HasFolder
false
2022/10/31 17:42:04 HasFolder duration: 8.6µs, args: /home/ras/ghq/github.com/Ras96/dotfiles/.git/rebase-merge
2022/10/31 17:42:04 debug: HasFolder
false
2022/10/31 17:42:04 HasFolder duration: 1.9µs, args: /home/ras/ghq/github.com/Ras96/dotfiles/.git/rebase-apply
2022/10/31 17:42:04 PathSeparator duration: 100ns, args: 
2022/10/31 17:42:04 debug: HasFilesInDir
false
2022/10/31 17:42:04 HasFilesInDir duration: 5µs, args: MERGE_MSG
2022/10/31 17:42:04 PathSeparator duration: 0s, args: 
2022/10/31 17:42:04 debug: HasFilesInDir
false
2022/10/31 17:42:04 HasFilesInDir duration: 3.8µs, args: CHERRY_PICK_HEAD
2022/10/31 17:42:04 PathSeparator duration: 0s, args: 
2022/10/31 17:42:04 debug: HasFilesInDir
false
2022/10/31 17:42:04 HasFilesInDir duration: 16.4µs, args: REVERT_HEAD
2022/10/31 17:42:04 PathSeparator duration: 100ns, args: 
2022/10/31 17:42:04 debug: HasFilesInDir
false
2022/10/31 17:42:04 HasFilesInDir duration: 3.3µs, args: sequencer/todo
2022/10/31 17:42:04 debug: FileContent
0000000000000000000000000000000000000000 dc4bb5fca2928189fb0f7fb99b5cbc1ff2a6d216 Ras96 <asymptote.k.k@gmail.com> 1663073129 +0900   On main: wsl
dc4bb5fca2928189fb0f7fb99b5cbc1ff2a6d216 2c7a29abcec342863d87f14ad2df81dd6a105007 Ras96 <asymptote.k.k@gmail.com> 1663073148 +0900   On main: wsl

2022/10/31 17:42:04 FileContent duration: 21.5µs, args: /home/ras/ghq/github.com/Ras96/dotfiles/.git/logs/refs/stash
2022/10/31 17:42:04 TemplateCache duration: 200ns, args: 
2022/10/31 17:42:04 TemplateCache duration: 200ns, args: 
2022/10/31 17:42:04 Shell duration: 400ns, args: 
2022/10/31 17:42:04 TemplateCache duration: 200ns, args: 
2022/10/31 17:42:04 debug: Pwd
/home/ras/ghq/github.com/Ras96/dotfiles
2022/10/31 17:42:04 Pwd duration: 1.7µs, args: 
2022/10/31 17:42:04 GOOS duration: 0s, args: 
2022/10/31 17:42:04 TemplateCache duration: 100ns, args: 
2022/10/31 17:42:04 TemplateCache duration: 100ns, args: 
2022/10/31 17:42:04 Shell duration: 400ns, args: 
2022/10/31 17:42:04 debug: Pwd
/home/ras/ghq/github.com/Ras96/dotfiles
2022/10/31 17:42:04 Pwd duration: 15µs, args: 
2022/10/31 17:42:04 GOOS duration: 100ns, args: 
2022/10/31 17:42:04 ExecutionTime duration: 100ns, args: 
2022/10/31 17:42:04 TemplateCache duration: 0s, args: 
2022/10/31 17:42:04 TemplateCache duration: 200ns, args: 
2022/10/31 17:42:04 Shell duration: 300ns, args: 
2022/10/31 17:42:04 debug: Pwd
/home/ras/ghq/github.com/Ras96/dotfiles
2022/10/31 17:42:04 Pwd duration: 1.3µs, args: 
2022/10/31 17:42:04 GOOS duration: 0s, args: 
2022/10/31 17:42:04 ErrorCode duration: 100ns, args: 
2022/10/31 17:42:04 ErrorCode duration: 0s, args: 
2022/10/31 17:42:04 Flags duration: 100ns, args: 
2022/10/31 17:42:04 debug: Pwd
/home/ras/ghq/github.com/Ras96/dotfiles
2022/10/31 17:42:04 Pwd duration: 1µs, args: 
2022/10/31 17:42:04 GOOS duration: 0s, args: 
2022/10/31 17:42:04 ErrorCode duration: 100ns, args: 
2022/10/31 17:42:04 TemplateCache duration: 100ns, args: 
2022/10/31 17:42:04 TemplateCache duration: 700ns, args: 
2022/10/31 17:42:04 Shell duration: 200ns, args: 
2022/10/31 17:42:04 TemplateCache duration: 400ns, args: 
2022/10/31 17:42:04 debug: Getenv

2022/10/31 17:42:04 Getenv duration: 2.5µs, args: XDG_CACHE_HOME
2022/10/31 17:42:04 CachePath duration: 19.7µs, args: 
2022/10/31 17:42:04 Flags duration: 100ns, args: 
/home/linuxbrew/.linuxbrew/Cellar/oh-my-posh/12.7.1/bin/oh-my-posh: command not found
- (line 37): 
    /home/linuxbrew/.linuxbrew/Cellar/oh-my-posh/12.7.1/bin/oh-my-posh print primary --config $POSH_THEME --shell fish --error $omp_status_cache --execution-time $omp_duration --stack-count $omp_stack_count --shell-version $FISH_VERSION
    ^
in function 'fish_prompt'
in command substitution
/home/linuxbrew/.linuxbrew/Cellar/oh-my-posh/12.7.1/bin/oh-my-posh: command not found
- (line 54): 
    /home/linuxbrew/.linuxbrew/Cellar/oh-my-posh/12.7.1/bin/oh-my-posh print right --config $POSH_THEME --shell fish --error $omp_status_cache --execution-time $omp_duration --stack-count $omp_stack_count --shell-version $FISH_VERSION
    ^
in function 'fish_right_prompt'
in command substitution
JanDeDobbeleer commented 2 years ago

@Ras96 it seems homebrew didn't add the executable to your PATH, or you didn't add homebrew's bin folder to the PATH (export PATH=/opt/homebrew/bin:$PATH -> double check the actual path)

ras0q commented 2 years ago

I have no problem with either.

In my envirinment, fish executes the following commands at startup

# at ~/.config/fish/config.fish
oh-my-posh init fish --config ~/.omp-theme.json | source

Then, brew upgrade will remove the old version of oh-my-posh and install the new version.

If you installed omp with brew, the output of oh-my-posh init depends on the version of it, so removing the old version will break its appearance.

Full outputs:

$ oh-my-posh init fish --config ~/.omp-theme.json 
set --export POSH_THEME /home/ras/.omp-theme.json
set --global POWERLINE_COMMAND "oh-my-posh"
set --global CONDA_PROMPT_MODIFIER false
set --global omp_tooltip_command ""
set --global omp_transient 0

# template function for context loading
function set_poshcontext
  return
end

function fish_prompt
    set --local omp_status_cache_temp $status
    # clear from cursor to end of screen as
    # commandline --function repaint does not do this
    # see https://github.com/fish-shell/fish-shell/issues/8418
    printf \e\[0J
    if test "$omp_transient" = "1"
      /home/linuxbrew/.linuxbrew/Cellar/oh-my-posh/12.10.0/bin/oh-my-posh print transient --config $POSH_THEME --shell fish --error $omp_status_cache --execution-time $omp_duration --stack-count $omp_stack_count --shell-version $FISH_VERSION
      return
    end
    set --global omp_status_cache $omp_status_cache_temp
    set --global omp_stack_count (count $dirstack)
    set --global omp_duration "$CMD_DURATION$cmd_duration"
    # check if variable set, < 3.2 case
    if set --query omp_lastcommand; and test "$omp_lastcommand" = ""
      set omp_duration 0
    end
    # works with fish >=3.2
    if set --query omp_last_status_generation; and test "$omp_last_status_generation" = "$status_generation"
      set omp_duration 0
    end
    if set --query status_generation
      set --global --export omp_last_status_generation $status_generation
    end
    set_poshcontext
    /home/linuxbrew/.linuxbrew/Cellar/oh-my-posh/12.10.0/bin/oh-my-posh print primary --config $POSH_THEME --shell fish --error $omp_status_cache --execution-time $omp_duration --stack-count $omp_stack_count --shell-version $FISH_VERSION
end

function fish_right_prompt
    if test "$omp_transient" = "1"
      echo -n ""
      set omp_transient 0
      return
    end
    if test -n "$omp_tooltip_command"
      set omp_tooltip_prompt (/home/linuxbrew/.linuxbrew/Cellar/oh-my-posh/12.10.0/bin/oh-my-posh print tooltip --config $POSH_THEME --shell fish --error $omp_status_cache --shell-version $FISH_VERSION --command $omp_tooltip_command)
      if test -n "$omp_tooltip_prompt"
        echo -n $omp_tooltip_prompt
        set omp_tooltip_command ""
        return
      end
    end
    /home/linuxbrew/.linuxbrew/Cellar/oh-my-posh/12.10.0/bin/oh-my-posh print right --config $POSH_THEME --shell fish --error $omp_status_cache --execution-time $omp_duration --stack-count $omp_stack_count --shell-version $FISH_VERSION
end

function postexec_omp --on-event fish_postexec
  # works with fish <3.2
  # pre and postexec not fired for empty command in fish >=3.2
  set --global --export omp_lastcommand $argv
end

# perform cleanup so a new initialization in current session works
if test "$(string match -e '_render_transient' $(bind \r --user 2>/dev/null))" != ''
  bind -e \r
end
if test "$(string match -e '_render_tooltip' $(bind \x20 --user 2>/dev/null))" != ''
  bind -e \x20
end

# tooltip

function _render_tooltip
  commandline --function expand-abbr
  set omp_tooltip_command (commandline --current-buffer | string collect)
  commandline --insert " "
  commandline --function repaint
end

if test "false" = "true"
  bind \x20 _render_tooltip
end

# transient prompt

function _render_transient
  if commandline --paging-mode
    commandline --function accept-autosuggestion
    return
  end
  set omp_transient 1
  commandline --function repaint
  commandline --function execute
end

if test "false" = "true"
  bind \r _render_transient
end

# legacy functions
function enable_poshtooltips
  return
end
function enable_poshtransientprompt
  return
end

I would like the output of oh-my-posh init to be version-independent.

ras0q commented 2 years ago

I resolved it with the -s flag. Thank you!

oh-my-posh init fish -s --config ~/.omp-theme.json | source
JanDeDobbeleer commented 2 years ago

ah, that's because we fetch the actual binary and indeed strict disables that.

github-actions[bot] commented 10 months ago

This issue has been automatically locked since there has not been any recent activity (i.e. last half year) after it was closed. It helps our maintainers focus on the active issues. If you have found a problem that seems similar, please open a discussion first, complete the body with all the details necessary to reproduce, and mention this issue as reference.