JanDeDobbeleer / oh-my-posh

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

WSL2 Bash-Prompt broken #1284

Closed GreenEyedAndy closed 2 years ago

GreenEyedAndy commented 2 years ago

Code of Conduct

What happened?

I followed the steps to install oh-my-posh for bash on wsl2 but after adding the call in .bashrc the prompt is broken:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x8a4407]

goroutine 1 [running]:
main.(*AnsiWriter).getAnsiFromColorString(...)
        /home/runner/work/oh-my-posh/oh-my-posh/src/writer_ansi.go:94
main.(*AnsiWriter).asAnsiColors(0xc000514300, {0xc0001da2d7, 0x0}, {0xc0001da2d0, 0x8})
        /home/runner/work/oh-my-posh/oh-my-posh/src/writer_ansi.go:175 +0x427
main.(*AnsiWriter).write(0xc000514300, {0xc0001da2d7, 0x7}, {0xc0001da2d0, 0x12ab4c0}, {0xc0000c1020, 0x20})
        /home/runner/work/oh-my-posh/oh-my-posh/src/writer_ansi.go:135 +0x77
main.(*Block).renderText(0xc00013ebb0, {0x7ffe7f423e18, 0x4})
        /home/runner/work/oh-my-posh/oh-my-posh/src/block.go:180 +0xbf
main.(*Block).renderPlainSegment(...)
        /home/runner/work/oh-my-posh/oh-my-posh/src/block.go:169
main.(*Block).renderSegmentText(0xc00013ebb0, {0x7ffe7f423e18, 0x7})
        /home/runner/work/oh-my-posh/oh-my-posh/src/block.go:153 +0x49
main.(*Block).renderSegments(0xc00013ebb0)
        /home/runner/work/oh-my-posh/oh-my-posh/src/block.go:100 +0x12c
main.(*engine).renderBlock(0xc000171df0, 0xc00013ebb0)
        /home/runner/work/oh-my-posh/oh-my-posh/src/engine.go:112 +0x90b
main.(*engine).render(0xc000171df0)
        /home/runner/work/oh-my-posh/oh-my-posh/src/engine.go:56 +0x58
main.main()
        /home/runner/work/oh-my-posh/oh-my-posh/src/main.go:248 +0xc4a

### Theme

jandedobbeleer.omp.json

### What OS are you seeing the problem on?

Linux

### Which shell are you using?

bash

### Log output

```shell
oh-my-posh --debug --shell uni --config="/home/andy/jandedobbeleer.omp.json"

Version: 6.11.0

Segments:

ConsoleTitle(true)   -   0 ms - uni in Andy
session(true)        -   0 ms -  andy 
path(true)           -   0 ms -    Andy 
git(false)           -  58 ms -
node(false)          -   3 ms -
go(false)            -   1 ms -
julia(false)         -   1 ms -
python(false)        -   4 ms -
ruby(false)          -   1 ms -
azfunc(false)        -   0 ms -
aws(false)           -   0 ms -
root(false)          -   0 ms -
executiontime(true)  -   0 ms -  ﮫ0ms⠀
exit(true)           -   0 ms -   
shell(true)          -   0 ms -   uni 
ytm(false)           -   0 ms -
battery(false)       -   0 ms -
time(true)           -   0 ms -  21:11:45 

Run duration: 73.8889ms

Logs:

2021/11/22 21:11:45 debug: getenv

2021/11/22 21:11:45 getenv duration: 6.1µs, args: XDG_CACHE_HOME
2021/11/22 21:11:45 getCachePath duration: 20.3µs, args:
2021/11/22 21:11:45 getArgs duration: 100ns, args:
2021/11/22 21:11:45 getArgs duration: 0s, args:
2021/11/22 21:11:45 getShellName duration: 500ns, args:
2021/11/22 21:11:45 debug: getenv

2021/11/22 21:11:45 getenv duration: 2µs, args: OMP_CACHE_DISABLED
2021/11/22 21:11:45 isRunningAsRoot duration: 900ns, args:
2021/11/22 21:11:45 getcwd duration: 695.7µs, args:
2021/11/22 21:11:45 getPathSeperator duration: 0s, args:
2021/11/22 21:11:45 getPathSeperator duration: 100ns, args:
2021/11/22 21:11:45 getPathSeperator duration: 0s, args:
2021/11/22 21:11:45 getPathSeperator duration: 0s, args:
2021/11/22 21:11:45 getPathSeperator duration: 100ns, args:
2021/11/22 21:11:45 getPathSeperator duration: 100ns, args:
2021/11/22 21:11:45 getShellName duration: 100ns, args:
2021/11/22 21:11:45 getCurrentUser duration: 300ns, args:
2021/11/22 21:11:45 getHostName duration: 1.7µs, args:
2021/11/22 21:11:45 getcwd duration: 200ns, args:
2021/11/22 21:11:45 getCurrentUser duration: 200ns, args:
2021/11/22 21:11:45 getRuntimeGOOS duration: 0s, args:
2021/11/22 21:11:45 debug: getenv

2021/11/22 21:11:45 getenv duration: 1.9µs, args: SSH_CONNECTION
2021/11/22 21:11:45 debug: getenv

2021/11/22 21:11:45 getenv duration: 1.4µs, args: SSH_CLIENT
2021/11/22 21:11:45 debug: getenv

2021/11/22 21:11:45 getenv duration: 1.1µs, args: POSH_SESSION_DEFAULT_USER
2021/11/22 21:11:45 getcwd duration: 100ns, args:
2021/11/22 21:11:45 getcwd duration: 0s, args:
2021/11/22 21:11:45 getArgs duration: 100ns, args:
2021/11/22 21:11:45 getcwd duration: 100ns, args:
2021/11/22 21:11:45 getRuntimeGOOS duration: 0s, args:
2021/11/22 21:11:45 getRuntimeGOOS duration: 0s, args:
2021/11/22 21:11:45 getPathSeperator duration: 0s, args:
2021/11/22 21:11:45 getPathSeperator duration: 0s, args:
2021/11/22 21:11:45 getPathSeperator duration: 0s, args:
2021/11/22 21:11:45 getPathSeperator duration: 100ns, args:
2021/11/22 21:11:45 getPathSeperator duration: 100ns, args:
2021/11/22 21:11:45 getPathSeperator duration: 0s, args:
2021/11/22 21:11:45 getPathSeperator duration: 0s, args:
2021/11/22 21:11:45 getRuntimeGOOS duration: 0s, args:
2021/11/22 21:11:45 getcwd duration: 0s, args:
2021/11/22 21:11:45 getRuntimeGOOS duration: 0s, args:
2021/11/22 21:11:45 debug: getenv
Ubuntu-20.04
2021/11/22 21:11:45 getenv duration: 1.1µs, args: WSL_DISTRO_NAME
2021/11/22 21:11:45 isWsl duration: 2.5µs, args:
2021/11/22 21:11:45 getcwd duration: 100ns, args:
2021/11/22 21:11:45 hasCommand duration: 58.2783ms, args: git.exe
2021/11/22 21:11:45 getcwd duration: 200ns, args:
2021/11/22 21:11:45 error: hasParentFilePath
stat /.git: no such file or directory
2021/11/22 21:11:45 hasParentFilePath duration: 434.9µs, args: .git
2021/11/22 21:11:45 getcwd duration: 100ns, args:
2021/11/22 21:11:45 getcwd duration: 100ns, args:
2021/11/22 21:11:45 getcwd duration: 0s, args:
2021/11/22 21:11:45 getPathSeperator duration: 0s, args:
2021/11/22 21:11:45 hasFiles duration: 1.5175ms, args: *.js
2021/11/22 21:11:45 getcwd duration: 100ns, args:
2021/11/22 21:11:45 getPathSeperator duration: 100ns, args:
2021/11/22 21:11:45 hasFiles duration: 1.3774ms, args: *.ts
2021/11/22 21:11:45 getcwd duration: 100ns, args:
2021/11/22 21:11:45 getPathSeperator duration: 0s, args:
2021/11/22 21:11:45 hasFiles duration: 165µs, args: package.json
2021/11/22 21:11:45 getcwd duration: 100ns, args:
2021/11/22 21:11:45 getPathSeperator duration: 0s, args:
2021/11/22 21:11:45 hasFiles duration: 159.8µs, args: .nvmrc
2021/11/22 21:11:45 getcwd duration: 0s, args:
2021/11/22 21:11:45 getPathSeperator duration: 0s, args:
2021/11/22 21:11:45 hasFiles duration: 156.7µs, args: pnpm-workspace.yaml
2021/11/22 21:11:45 getcwd duration: 0s, args:
2021/11/22 21:11:45 getPathSeperator duration: 0s, args:
2021/11/22 21:11:45 hasFiles duration: 161.7µs, args: .pnpmfile.cjs
2021/11/22 21:11:45 getcwd duration: 0s, args:
2021/11/22 21:11:45 getPathSeperator duration: 0s, args:
2021/11/22 21:11:45 hasFiles duration: 249.6µs, args: .npmrc
2021/11/22 21:11:45 getcwd duration: 100ns, args:
2021/11/22 21:11:45 getcwd duration: 0s, args:
2021/11/22 21:11:45 getcwd duration: 0s, args:
2021/11/22 21:11:45 getPathSeperator duration: 0s, args:
2021/11/22 21:11:45 hasFiles duration: 1.2471ms, args: *.go
2021/11/22 21:11:45 getcwd duration: 100ns, args:
2021/11/22 21:11:45 getPathSeperator duration: 0s, args:
2021/11/22 21:11:45 hasFiles duration: 151.8µs, args: go.mod
2021/11/22 21:11:45 getcwd duration: 0s, args:
2021/11/22 21:11:45 getcwd duration: 100ns, args:
2021/11/22 21:11:45 getcwd duration: 0s, args:
2021/11/22 21:11:45 getPathSeperator duration: 0s, args:
2021/11/22 21:11:45 hasFiles duration: 1.3122ms, args: *.jl
2021/11/22 21:11:45 getcwd duration: 100ns, args:
2021/11/22 21:11:45 getcwd duration: 100ns, args:
2021/11/22 21:11:45 getcwd duration: 0s, args:
2021/11/22 21:11:45 getPathSeperator duration: 100ns, args:
2021/11/22 21:11:45 hasFiles duration: 1.9852ms, args: *.py
2021/11/22 21:11:45 getcwd duration: 200ns, args:
2021/11/22 21:11:45 getPathSeperator duration: 100ns, args:
2021/11/22 21:11:45 hasFiles duration: 1.6995ms, args: *.ipynb
2021/11/22 21:11:45 getcwd duration: 100ns, args:
2021/11/22 21:11:45 getPathSeperator duration: 0s, args:
2021/11/22 21:11:45 hasFiles duration: 163.5µs, args: pyproject.toml
2021/11/22 21:11:45 getcwd duration: 100ns, args:
2021/11/22 21:11:45 getPathSeperator duration: 100ns, args:
2021/11/22 21:11:45 hasFiles duration: 150.4µs, args: venv.bak
2021/11/22 21:11:45 getcwd duration: 100ns, args:
2021/11/22 21:11:45 getPathSeperator duration: 100ns, args:
2021/11/22 21:11:45 hasFiles duration: 146.6µs, args: venv
2021/11/22 21:11:45 getcwd duration: 100ns, args:
2021/11/22 21:11:45 getPathSeperator duration: 0s, args:
2021/11/22 21:11:45 hasFiles duration: 147.8µs, args: .venv
2021/11/22 21:11:45 getcwd duration: 100ns, args:
2021/11/22 21:11:45 getcwd duration: 0s, args:
2021/11/22 21:11:45 getcwd duration: 0s, args:
2021/11/22 21:11:45 getPathSeperator duration: 0s, args:
2021/11/22 21:11:45 hasFiles duration: 1.1597ms, args: *.rb
2021/11/22 21:11:45 getcwd duration: 100ns, args:
2021/11/22 21:11:45 getPathSeperator duration: 100ns, args:
2021/11/22 21:11:45 hasFiles duration: 149.6µs, args: Rakefile
2021/11/22 21:11:45 getcwd duration: 100ns, args:
2021/11/22 21:11:45 getPathSeperator duration: 100ns, args:
2021/11/22 21:11:45 hasFiles duration: 146.6µs, args: Gemfile
2021/11/22 21:11:45 getcwd duration: 0s, args:
2021/11/22 21:11:45 getcwd duration: 100ns, args:
2021/11/22 21:11:45 getcwd duration: 0s, args:
2021/11/22 21:11:45 getPathSeperator duration: 0s, args:
2021/11/22 21:11:45 hasFiles duration: 146.8µs, args: host.json
2021/11/22 21:11:45 getcwd duration: 100ns, args:
2021/11/22 21:11:45 getPathSeperator duration: 0s, args:
2021/11/22 21:11:45 hasFiles duration: 147.6µs, args: local.settings.json
2021/11/22 21:11:45 getcwd duration: 100ns, args:
2021/11/22 21:11:45 getPathSeperator duration: 0s, args:
2021/11/22 21:11:45 hasFiles duration: 146.4µs, args: function.json
2021/11/22 21:11:45 getcwd duration: 100ns, args:
2021/11/22 21:11:45 debug: getenv

2021/11/22 21:11:45 getenv duration: 1.4µs, args: AWS_VAULT
2021/11/22 21:11:45 debug: getenv

2021/11/22 21:11:45 getenv duration: 800ns, args: AWS_PROFILE
2021/11/22 21:11:45 debug: getenv

2021/11/22 21:11:45 getenv duration: 600ns, args: AWS_REGION
2021/11/22 21:11:45 debug: getenv

2021/11/22 21:11:45 getenv duration: 700ns, args: AWS_DEFAULT_REGION
2021/11/22 21:11:45 debug: getenv

2021/11/22 21:11:45 getenv duration: 900ns, args: AWS_CONFIG_FILE
2021/11/22 21:11:45 error: getFileContent
open /home/andy/.aws/config: no such file or directory
2021/11/22 21:11:45 getFileContent duration: 539.1µs, args: /home/andy/.aws/config
2021/11/22 21:11:45 getcwd duration: 100ns, args:
2021/11/22 21:11:45 isRunningAsRoot duration: 900ns, args:
2021/11/22 21:11:45 getcwd duration: 0s, args:
2021/11/22 21:11:45 executionTime duration: 300ns, args:
2021/11/22 21:11:45 getcwd duration: 100ns, args:
2021/11/22 21:11:45 lastErrorCode duration: 100ns, args:
2021/11/22 21:11:45 getcwd duration: 100ns, args:
2021/11/22 21:11:45 getShellName duration: 400ns, args:
2021/11/22 21:11:45 getcwd duration: 100ns, args:
2021/11/22 21:11:45 error: doGet
Get "http://127.0.0.1:9863/query": dial tcp 127.0.0.1:9863: connect: connection refused
2021/11/22 21:11:45 doGet duration: 205.3µs, args: http://127.0.0.1:9863/query
2021/11/22 21:11:45 getcwd duration: 100ns, args:
2021/11/22 21:11:45 getBatteryInfo duration: 15.3µs, args:
2021/11/22 21:11:45 getcwd duration: 100ns, args:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x8a4407]

goroutine 1 [running]:
main.(*AnsiWriter).getAnsiFromColorString(...)
        /home/runner/work/oh-my-posh/oh-my-posh/src/writer_ansi.go:94
main.(*AnsiWriter).asAnsiColors(0xc000392300, {0xc00021a367, 0x0}, {0xc00021a360, 0x8})
        /home/runner/work/oh-my-posh/oh-my-posh/src/writer_ansi.go:175 +0x427
main.(*AnsiWriter).write(0xc000392300, {0xc00021a367, 0x7}, {0xc00021a360, 0x12ae2c0}, {0xc0000270e0, 0x20})
        /home/runner/work/oh-my-posh/oh-my-posh/src/writer_ansi.go:135 +0x77
main.(*Block).renderText(0xc000190bb0, {0x7ffc703c8e18, 0x4})
        /home/runner/work/oh-my-posh/oh-my-posh/src/block.go:180 +0xbf
main.(*Block).renderPlainSegment(...)
        /home/runner/work/oh-my-posh/oh-my-posh/src/block.go:169
main.(*Block).renderSegmentText(0xc000190bb0, {0x7ffc703c8e18, 0x7})
        /home/runner/work/oh-my-posh/oh-my-posh/src/block.go:153 +0x49
main.(*Block).renderSegments(0xc000190bb0)
        /home/runner/work/oh-my-posh/oh-my-posh/src/block.go:100 +0x12c
main.(*engine).renderBlock(0xc0001c1df0, 0xc000190bb0)
        /home/runner/work/oh-my-posh/oh-my-posh/src/engine.go:112 +0x90b
main.(*engine).render(0xc0001c1df0)
        /home/runner/work/oh-my-posh/oh-my-posh/src/engine.go:56 +0x58
main.main()
        /home/runner/work/oh-my-posh/oh-my-posh/src/main.go:248 +0xc4a
JanDeDobbeleer commented 2 years ago

@GreenEyedAndy is this the standard jandedobbeleer theme?

GreenEyedAndy commented 2 years ago

Yes, that‘s why I didn‘t post it ;-)

JanDeDobbeleer commented 2 years ago

I'm looking right now. This is going to be something silly.

oalders commented 2 years ago

I'm seeing this on macOS as well. Starts at v6.11.0.

JanDeDobbeleer commented 2 years ago

Fix incoming, we missed something.

github-actions[bot] commented 6 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.