JanDeDobbeleer / oh-my-posh

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

Python segment broken with pyenv virtualenv created using system version #2569

Closed shyun3 closed 2 years ago

shyun3 commented 2 years ago

Code of Conduct

What happened?

The python segment shows an error message if a pyenv virtualenv was created based on the system Python version. For example:

$ pyenv version
system (set by /home/user/.pyenv/version)
$ pyenv virtualenv demo
$ pyenv activate demo

The result is a segment like the following: image

But querying Python about the version works fine:

$ python --version
Python 3.8.10

Theme

{
  "background": "#906cff",
  "foreground": "#100e23",
  "powerline_symbol": "\ue0b0",
  "style": "powerline",
  "template": "\u2800\ue235 {{ if .Error }}{{ .Error }}{{ else }}{{ if .Venv }}{{ .Venv }} {{ end }}{{ .Full }}{{ end }}\u2800",
  "type": "python"
}

What OS are you seeing the problem on?

Windows, Linux

Which shell are you using?

bash

Log output

Version: 8.22.3

Segments:

ConsoleTitle(true) -   0 ms - user@host:~
root(false)    -   0 ms -
session(true)  -   0 ms - ⠀user@host⠀
path(true)     -   1 ms - ⠀~⠀
git(false)     -   0 ms -
python(true)   -   9 ms - ⠀ err parsing info from  with demo⠀
exit(false)    -   0 ms -
time(true)     -   0 ms - ⠀ 18:45:00⠀
text(true)     -   0 ms - ❯⠀

Run duration: 12.398108ms

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

Config path: /home/user/projects/dotfiles/mytheme.omp.json

Logs:

2022/07/25 18:45:00 debug: Getenv

2022/07/25 18:45:00 Getenv duration: 8.252µs, args: XDG_CACHE_HOME
2022/07/25 18:45:00 CachePath duration: 18.255µs, args:
2022/07/25 18:45:00 debug: Getenv
/home/user/projects/dotfiles/mytheme.omp.json
2022/07/25 18:45:00 Getenv duration: 1.495µs, args: POSH_THEME
2022/07/25 18:45:00 resolveConfigPath duration: 2.969µs, args:
2022/07/25 18:45:00 Init duration: 52.871µs, args:
2022/07/25 18:45:00 Flags duration: 41ns, args:
2022/07/25 18:45:00 config.loadConfig duration: 230.164µs, args:
2022/07/25 18:45:00 Flags duration: 40ns, args:
2022/07/25 18:45:00 debug: Getenv

2022/07/25 18:45:00 Getenv duration: 774ns, args: OMP_CACHE_DISABLED
2022/07/25 18:45:00 Root duration: 284ns, args:
2022/07/25 18:45:00 Shell duration: 202.928µs, args:
2022/07/25 18:45:00 ErrorCode duration: 53ns, args:
2022/07/25 18:45:00 debug: Getenv
Ubuntu
2022/07/25 18:45:00 Getenv duration: 942ns, args: WSL_DISTRO_NAME
2022/07/25 18:45:00 IsWsl duration: 2.107µs, args:
2022/07/25 18:45:00 debug: Pwd
/home/user
2022/07/25 18:45:00 Pwd duration: 7.63µs, args:
2022/07/25 18:45:00 PathSeparator duration: 54ns, args:
2022/07/25 18:45:00 PathSeparator duration: 23ns, args:
2022/07/25 18:45:00 debug: User
user
2022/07/25 18:45:00 User duration: 568ns, args:
2022/07/25 18:45:00 debug: Host
host
2022/07/25 18:45:00 Host duration: 1.708µs, args:
2022/07/25 18:45:00 GOOS duration: 44ns, args:
2022/07/25 18:45:00 TemplateCache duration: 235.776µs, args:
2022/07/25 18:45:00 Flags duration: 48ns, args:
2022/07/25 18:45:00 debug: Pwd
/home/user
2022/07/25 18:45:00 Pwd duration: 572ns, args:
2022/07/25 18:45:00 GOOS duration: 41ns, args:
2022/07/25 18:45:00 Root duration: 272ns, args:
2022/07/25 18:45:00 debug: Pwd
/home/user
2022/07/25 18:45:00 Pwd duration: 499ns, args:
2022/07/25 18:45:00 GOOS duration: 22ns, args:
2022/07/25 18:45:00 debug: Getenv

2022/07/25 18:45:00 Getenv duration: 660ns, args: SSH_CONNECTION
2022/07/25 18:45:00 debug: Getenv

2022/07/25 18:45:00 Getenv duration: 506ns, args: SSH_CLIENT
2022/07/25 18:45:00 TemplateCache duration: 42ns, args:
2022/07/25 18:45:00 TemplateCache duration: 116ns, args:
2022/07/25 18:45:00 Shell duration: 77ns, args:
2022/07/25 18:45:00 debug: Pwd
/home/user
2022/07/25 18:45:00 Pwd duration: 982ns, args:
2022/07/25 18:45:00 GOOS duration: 38ns, args:
2022/07/25 18:45:00 debug: Pwd
/home/user
2022/07/25 18:45:00 Pwd duration: 425ns, args:
2022/07/25 18:45:00 Flags duration: 49ns, args:
2022/07/25 18:45:00 debug: Pwd
/home/user
2022/07/25 18:45:00 Pwd duration: 393ns, args:
2022/07/25 18:45:00 GOOS duration: 21ns, args:
2022/07/25 18:45:00 GOOS duration: 31ns, args:
2022/07/25 18:45:00 PathSeparator duration: 44ns, args:
2022/07/25 18:45:00 PathSeparator duration: 22ns, args:
2022/07/25 18:45:00 GOOS duration: 20ns, args:
2022/07/25 18:45:00 debug: Getenv
Ubuntu
2022/07/25 18:45:00 Getenv duration: 622ns, args: WSL_DISTRO_NAME
2022/07/25 18:45:00 IsWsl duration: 1.496µs, args:
2022/07/25 18:45:00 debug: RunCommand
//wsl$/Ubuntu/home/user
2022/07/25 18:45:00 RunCommand duration: 1.373848ms, args: wslpath -m /home/user
2022/07/25 18:45:00 StackCount duration: 47ns, args:
2022/07/25 18:45:00 DirIsWritable duration: 3.304µs, args:
2022/07/25 18:45:00 TemplateCache duration: 58ns, args:
2022/07/25 18:45:00 TemplateCache duration: 188ns, args:
2022/07/25 18:45:00 Shell duration: 134ns, args:
2022/07/25 18:45:00 debug: Pwd
/home/user
2022/07/25 18:45:00 Pwd duration: 854ns, args:
2022/07/25 18:45:00 GOOS duration: 36ns, args:
2022/07/25 18:45:00 debug: Getenv
Ubuntu
2022/07/25 18:45:00 Getenv duration: 700ns, args: WSL_DISTRO_NAME
2022/07/25 18:45:00 IsWsl duration: 1.79µs, args:
2022/07/25 18:45:00 debug: Pwd
/home/user
2022/07/25 18:45:00 Pwd duration: 779ns, args:
2022/07/25 18:45:00 GOOS duration: 22ns, args:
2022/07/25 18:45:00 HasCommand duration: 15.119µs, args: git
2022/07/25 18:45:00 debug: Pwd
/home/user
2022/07/25 18:45:00 Pwd duration: 462ns, args:
2022/07/25 18:45:00 error: HasParentFilePath
stat /.git: no such file or directory
2022/07/25 18:45:00 HasParentFilePath duration: 9.061µs, args: .git
2022/07/25 18:45:00 debug: Pwd
/home/user
2022/07/25 18:45:00 Pwd duration: 536ns, args:
2022/07/25 18:45:00 GOOS duration: 34ns, args:
2022/07/25 18:45:00 debug: Pwd
/home/user
2022/07/25 18:45:00 Pwd duration: 428ns, args:
2022/07/25 18:45:00 debug: Getenv
/home/user/.pyenv/versions/demo
2022/07/25 18:45:00 Getenv duration: 650ns, args: VIRTUAL_ENV
2022/07/25 18:45:00 PathSeparator duration: 53ns, args:
2022/07/25 18:45:00 PathSeparator duration: 25ns, args:
2022/07/25 18:45:00 PathSeparator duration: 22ns, args:
2022/07/25 18:45:00 PathSeparator duration: 22ns, args:
2022/07/25 18:45:00 PathSeparator duration: 23ns, args:
2022/07/25 18:45:00 PathSeparator duration: 22ns, args:
2022/07/25 18:45:00 HasCommand duration: 4.832µs, args: python
2022/07/25 18:45:00 debug: Getenv
/home/user/.pyenv
2022/07/25 18:45:00 Getenv duration: 600ns, args: PYENV_ROOT
2022/07/25 18:45:00 debug: RunCommand
demo
2022/07/25 18:45:00 RunCommand duration: 9.250636ms, args: pyenv version-name
2022/07/25 18:45:00 debug: Getenv
/home/user/.pyenv
2022/07/25 18:45:00 Getenv duration: 2.263µs, args: PYENV_ROOT
2022/07/25 18:45:00 debug: Getenv
/home/user/.pyenv
2022/07/25 18:45:00 Getenv duration: 648ns, args: PYENV_ROOT
2022/07/25 18:45:00 TemplateCache duration: 138ns, args:
2022/07/25 18:45:00 TemplateCache duration: 107ns, args:
2022/07/25 18:45:00 Shell duration: 143ns, args:
2022/07/25 18:45:00 debug: Pwd
/home/user
2022/07/25 18:45:00 Pwd duration: 930ns, args:
2022/07/25 18:45:00 GOOS duration: 43ns, args:
2022/07/25 18:45:00 ErrorCode duration: 49ns, args:
2022/07/25 18:45:00 ErrorCode duration: 21ns, args:
2022/07/25 18:45:00 Flags duration: 45ns, args:
2022/07/25 18:45:00 debug: Pwd
/home/user
2022/07/25 18:45:00 Pwd duration: 474ns, args:
2022/07/25 18:45:00 GOOS duration: 22ns, args:
2022/07/25 18:45:00 TemplateCache duration: 48ns, args:
2022/07/25 18:45:00 TemplateCache duration: 74ns, args:
2022/07/25 18:45:00 Shell duration: 91ns, args:
2022/07/25 18:45:00 Flags duration: 67ns, args:
2022/07/25 18:45:00 debug: Pwd
/home/user
2022/07/25 18:45:00 Pwd duration: 633ns, args:
2022/07/25 18:45:00 GOOS duration: 40ns, args:
2022/07/25 18:45:00 TemplateCache duration: 50ns, args:
2022/07/25 18:45:00 TemplateCache duration: 27ns, args:
2022/07/25 18:45:00 Shell duration: 63ns, args:
2022/07/25 18:45:00 debug: Getenv

2022/07/25 18:45:00 Getenv duration: 914ns, args: XDG_CACHE_HOME
2022/07/25 18:45:00 CachePath duration: 7.89µs, args:
2022/07/25 18:45:00 Flags duration: 34ns, args:
JanDeDobbeleer commented 2 years ago

@shyun3 can you get me the logs on the latest version? I added more debug logging as the core parts were missing...

shyun3 commented 2 years ago

The latest version I see in Homebrew is v8.22.4 but the latest release in GitHub is v8.22.6. Do you know how long it takes for Homebrew to catch up?

JanDeDobbeleer commented 2 years ago

@shyun3 what homebrew source do you have? The core version is slower (and not mine), please follow the guide to ensure you have the right version.

shyun3 commented 2 years ago

Got the latest version and here's the log:

Version: 8.22.6

Segments:

ConsoleTitle(true) -   0 ms - user@host:~
root(false)    -   0 ms -
session(true)  -   0 ms - ⠀user@host
path(true)     -   1 ms - ⠀~⠀
git(false)     -   0 ms -
python(true)   -   9 ms - ⠀ err parsing info from  with demo⠀
exit(false)    -   0 ms -
time(true)     -   0 ms - ⠀ 10:20:41⠀
text(true)     -   0 ms - ❯⠀

Run duration: 12.569737ms

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

Config path: /home/user/projects/dotfiles/mytheme.omp.json

Logs:

2022/07/26 10:20:41 debug: Getenv

2022/07/26 10:20:41 Getenv duration: 8.971µs, args: XDG_CACHE_HOME
2022/07/26 10:20:41 CachePath duration: 18.356µs, args:
2022/07/26 10:20:41 debug: Getenv
/home/user/projects/dotfiles/mytheme.omp.json
2022/07/26 10:20:41 Getenv duration: 5.791µs, args: POSH_THEME
2022/07/26 10:20:41 resolveConfigPath duration: 7.5µs, args:
2022/07/26 10:20:41 Init duration: 62.795µs, args:
2022/07/26 10:20:41 Flags duration: 46ns, args:
2022/07/26 10:20:41 config.loadConfig duration: 256.135µs, args:
2022/07/26 10:20:41 Flags duration: 54ns, args:
2022/07/26 10:20:41 debug: Getenv

2022/07/26 10:20:41 Getenv duration: 889ns, args: OMP_CACHE_DISABLED
2022/07/26 10:20:41 Root duration: 292ns, args:
2022/07/26 10:20:41 Shell duration: 191.799µs, args:
2022/07/26 10:20:41 ErrorCode duration: 59ns, args:
2022/07/26 10:20:41 debug: Getenv
Ubuntu
2022/07/26 10:20:41 Getenv duration: 892ns, args: WSL_DISTRO_NAME
2022/07/26 10:20:41 IsWsl duration: 2.215µs, args:
2022/07/26 10:20:41 debug: Pwd
/home/user
2022/07/26 10:20:41 Pwd duration: 6.831µs, args:
2022/07/26 10:20:41 PathSeparator duration: 53ns, args:
2022/07/26 10:20:41 PathSeparator duration: 31ns, args:
2022/07/26 10:20:41 debug: User
user
2022/07/26 10:20:41 User duration: 594ns, args:
2022/07/26 10:20:41 debug: Host
host
2022/07/26 10:20:41 Host duration: 1.333µs, args:
2022/07/26 10:20:41 GOOS duration: 43ns, args:
2022/07/26 10:20:41 TemplateCache duration: 226.173µs, args:
2022/07/26 10:20:41 Flags duration: 49ns, args:
2022/07/26 10:20:41 debug: Pwd
/home/user
2022/07/26 10:20:41 Pwd duration: 905ns, args:
2022/07/26 10:20:41 GOOS duration: 45ns, args:
2022/07/26 10:20:41 Root duration: 211ns, args:
2022/07/26 10:20:41 debug: Pwd
/home/user
2022/07/26 10:20:41 Pwd duration: 460ns, args:
2022/07/26 10:20:41 GOOS duration: 21ns, args:
2022/07/26 10:20:41 debug: Getenv

2022/07/26 10:20:41 Getenv duration: 640ns, args: SSH_CONNECTION
2022/07/26 10:20:41 debug: Getenv

2022/07/26 10:20:41 Getenv duration: 526ns, args: SSH_CLIENT
2022/07/26 10:20:41 TemplateCache duration: 42ns, args:
2022/07/26 10:20:41 TemplateCache duration: 129ns, args:
2022/07/26 10:20:41 Shell duration: 67ns, args:
2022/07/26 10:20:41 debug: Pwd
/home/user
2022/07/26 10:20:41 Pwd duration: 1.209µs, args:
2022/07/26 10:20:41 GOOS duration: 49ns, args:
2022/07/26 10:20:41 debug: Pwd
/home/user
2022/07/26 10:20:41 Pwd duration: 616ns, args:
2022/07/26 10:20:41 Flags duration: 47ns, args:
2022/07/26 10:20:41 debug: Pwd
/home/user
2022/07/26 10:20:41 Pwd duration: 592ns, args:
2022/07/26 10:20:41 GOOS duration: 49ns, args:
2022/07/26 10:20:41 GOOS duration: 44ns, args:
2022/07/26 10:20:41 PathSeparator duration: 70ns, args:
2022/07/26 10:20:41 PathSeparator duration: 28ns, args:
2022/07/26 10:20:41 GOOS duration: 22ns, args:
2022/07/26 10:20:41 debug: Getenv
Ubuntu
2022/07/26 10:20:41 Getenv duration: 864ns, args: WSL_DISTRO_NAME
2022/07/26 10:20:41 IsWsl duration: 2.215µs, args:
2022/07/26 10:20:41 debug: RunCommand
//wsl$/Ubuntu/home/user
2022/07/26 10:20:41 RunCommand duration: 1.250142ms, args: wslpath -m /home/user
2022/07/26 10:20:41 StackCount duration: 56ns, args:
2022/07/26 10:20:41 DirIsWritable duration: 2.637µs, args:
2022/07/26 10:20:41 TemplateCache duration: 56ns, args:
2022/07/26 10:20:41 TemplateCache duration: 151ns, args:
2022/07/26 10:20:41 Shell duration: 174ns, args:
2022/07/26 10:20:41 debug: Pwd
/home/user
2022/07/26 10:20:41 Pwd duration: 839ns, args:
2022/07/26 10:20:41 GOOS duration: 45ns, args:
2022/07/26 10:20:41 debug: Getenv
Ubuntu
2022/07/26 10:20:41 Getenv duration: 780ns, args: WSL_DISTRO_NAME
2022/07/26 10:20:41 IsWsl duration: 1.862µs, args:
2022/07/26 10:20:41 debug: Pwd
/home/user
2022/07/26 10:20:41 Pwd duration: 810ns, args:
2022/07/26 10:20:41 GOOS duration: 21ns, args:
2022/07/26 10:20:41 debug: CommandPath
/usr/bin/git
2022/07/26 10:20:41 CommandPath duration: 14.785µs, args: git
2022/07/26 10:20:41 HasCommand duration: 15.908µs, args: git
2022/07/26 10:20:41 debug: Pwd
/home/user
2022/07/26 10:20:41 Pwd duration: 1.33µs, args:
2022/07/26 10:20:41 error: HasParentFilePath
stat /.git: no such file or directory
2022/07/26 10:20:41 HasParentFilePath duration: 418.891µs, args: .git
2022/07/26 10:20:41 debug: Pwd
/home/user
2022/07/26 10:20:41 Pwd duration: 692ns, args:
2022/07/26 10:20:41 GOOS duration: 49ns, args:
2022/07/26 10:20:41 debug: Pwd
/home/user
2022/07/26 10:20:41 Pwd duration: 436ns, args:
2022/07/26 10:20:41 debug: Getenv
/home/user/.pyenv/versions/demo
2022/07/26 10:20:41 Getenv duration: 678ns, args: VIRTUAL_ENV
2022/07/26 10:20:41 PathSeparator duration: 51ns, args:
2022/07/26 10:20:41 PathSeparator duration: 21ns, args:
2022/07/26 10:20:41 PathSeparator duration: 20ns, args:
2022/07/26 10:20:41 PathSeparator duration: 21ns, args:
2022/07/26 10:20:41 PathSeparator duration: 21ns, args:
2022/07/26 10:20:41 PathSeparator duration: 21ns, args:
2022/07/26 10:20:41 debug: CommandPath
/home/user/.pyenv/shims/python
2022/07/26 10:20:41 CommandPath duration: 7.363µs, args: python
2022/07/26 10:20:41 debug: Getenv
/home/user/.pyenv
2022/07/26 10:20:41 Getenv duration: 616ns, args: PYENV_ROOT
2022/07/26 10:20:41 debug: RunCommand
demo
2022/07/26 10:20:41 RunCommand duration: 9.030731ms, args: pyenv version-name
2022/07/26 10:20:41 debug: ResolveSymlink
/home/user/.pyenv/versions/demo
2022/07/26 10:20:41 ResolveSymlink duration: 6.899µs, args: /home/user/.pyenv/versions/demo
2022/07/26 10:20:41 TemplateCache duration: 225ns, args:
2022/07/26 10:20:41 TemplateCache duration: 177ns, args:
2022/07/26 10:20:41 Shell duration: 153ns, args:
2022/07/26 10:20:41 debug: Pwd
/home/user
2022/07/26 10:20:41 Pwd duration: 881ns, args:
2022/07/26 10:20:41 GOOS duration: 40ns, args:
2022/07/26 10:20:41 ErrorCode duration: 38ns, args:
2022/07/26 10:20:41 ErrorCode duration: 20ns, args:
2022/07/26 10:20:41 Flags duration: 48ns, args:
2022/07/26 10:20:41 debug: Pwd
/home/user
2022/07/26 10:20:41 Pwd duration: 532ns, args:
2022/07/26 10:20:41 GOOS duration: 20ns, args:
2022/07/26 10:20:41 TemplateCache duration: 27ns, args:
2022/07/26 10:20:41 TemplateCache duration: 73ns, args:
2022/07/26 10:20:41 Shell duration: 51ns, args:
2022/07/26 10:20:41 Flags duration: 62ns, args:
2022/07/26 10:20:41 debug: Pwd
/home/user
2022/07/26 10:20:41 Pwd duration: 668ns, args:
2022/07/26 10:20:41 GOOS duration: 35ns, args:
2022/07/26 10:20:41 TemplateCache duration: 28ns, args:
2022/07/26 10:20:41 TemplateCache duration: 68ns, args:
2022/07/26 10:20:41 Shell duration: 72ns, args:
2022/07/26 10:20:41 debug: Getenv

2022/07/26 10:20:41 Getenv duration: 830ns, args: XDG_CACHE_HOME
2022/07/26 10:20:41 CachePath duration: 6.843µs, args:
2022/07/26 10:20:41 Flags duration: 52ns, args:
github-actions[bot] commented 9 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.