oh-my-posh: Plain text ANSI - SetConsoleMode fails on older versions of Windows 10
Prerequisites
-
[*] I have read and understand the
CONTRIBUTINGguide -
[*] I looked for duplicate issues before submitting this one
Description
I followed the docs and upgraded oh my posh 2 to V3 on my Win10 machine using Powershell in admin mode. When I run the terminal I get the following exception:
PC=0x50c79a0000
syscall.loadsystemlibrary(0xc000010e00, 0xc000012800, 0xc000012800, 0x20)
C:/hostedtoolcache/windows/go/1.15.2/x64/src/runtime/syscall_windows.go:136 +0xe7
syscall.LoadDLL(0xfe1e92, 0xb, 0xc000024000, 0xc00001a000, 0xc0000758d8)
C:/hostedtoolcache/windows/go/1.15.2/x64/src/syscall/dll_windows.go:81 +0x16a
syscall.(*LazyDLL).Load(0xc0000041e0, 0x0, 0x0)
C:/hostedtoolcache/windows/go/1.15.2/x64/src/syscall/dll_windows.go:245 +0xc8
syscall.(*LazyProc).Find(0xc000043bf0, 0x0, 0x0)
C:/hostedtoolcache/windows/go/1.15.2/x64/src/syscall/dll_windows.go:300 +0xbf
syscall.(*LazyProc).mustFind(...)
C:/hostedtoolcache/windows/go/1.15.2/x64/src/syscall/dll_windows.go:318
syscall.(*LazyProc).Addr(...)
C:/hostedtoolcache/windows/go/1.15.2/x64/src/syscall/dll_windows.go:327
syscall.GetUserProfileDirectory(0x1f4, 0xc0001241a0, 0xc0000759b8, 0xc0001241a0, 0x509fe3f4a0
)
C:/hostedtoolcache/windows/go/1.15.2/x64/src/syscall/zsyscall_windows.go:1910 +0x3e
syscall.Token.GetUserProfileDirectory(0x1f4, 0xc00000ef90, 0x2c, 0x0, 0x0)
C:/hostedtoolcache/windows/go/1.15.2/x64/src/syscall/security_windows.go:368 +0x8f
os/user.current(0x0, 0x0, 0x0)
C:/hostedtoolcache/windows/go/1.15.2/x64/src/os/user/lookup_windows.go:217 +0x1c7
os/user.Current.func1()
C:/hostedtoolcache/windows/go/1.15.2/x64/src/os/user/lookup.go:15 +0x29
sync.(*Once).doSlow(0x10f7de0, 0xfef020)
C:/hostedtoolcache/windows/go/1.15.2/x64/src/sync/once.go:66 +0xf7
sync.(*Once).Do(...)
C:/hostedtoolcache/windows/go/1.15.2/x64/src/sync/once.go:57
os/user.Current(0xc0001029c0, 0xc000102990, 0xc000005a60)
C:/hostedtoolcache/windows/go/1.15.2/x64/src/os/user/lookup.go:15 +0x105
main.(*environment).getCurrentUser(0xc000006050, 0xc000005a00, 0xc0000059e0, 0xc0000059c0)
D:/a/oh-my-posh3/oh-my-posh3/src/github.com/JanDeDobbeleer/oh-my-posh3/environment.go
:99 +0x29
main.(*session).getUserName(0xc0000059a0, 0x0, 0x0)
D:/a/oh-my-posh3/oh-my-posh3/src/github.com/JanDeDobbeleer/oh-my-posh3/segment_sessio
n.go:64 +0x68
main.(*session).getFormattedText(0xc0000059a0, 0x0, 0x0)
D:/a/oh-my-posh3/oh-my-posh3/src/github.com/JanDeDobbeleer/oh-my-posh3/segment_sessio
n.go:40 +0x47
main.(*session).string(0xc0000059a0, 0x1017801, 0xc000006050)
D:/a/oh-my-posh3/oh-my-posh3/src/github.com/JanDeDobbeleer/oh-my-posh3/segment_sessio
n.go:31 +0x32
main.(*Segment).string(...)
D:/a/oh-my-posh3/oh-my-posh3/src/github.com/JanDeDobbeleer/oh-my-posh3/segment.go:72
main.(*engine).renderBlockSegments(0xc000075f40, 0xc0000401e0, 0x0, 0x0)
D:/a/oh-my-posh3/oh-my-posh3/src/github.com/JanDeDobbeleer/oh-my-posh3/engine.go:97 +
0x1c3
main.(*engine).render(0xc000075f40)
D:/a/oh-my-posh3/oh-my-posh3/src/github.com/JanDeDobbeleer/oh-my-posh3/engine.go:126
+0xe5
main.main()
D:/a/oh-my-posh3/oh-my-posh3/src/github.com/JanDeDobbeleer/oh-my-posh3/main.go:64 +0x
3f5
rax 0x7ffe253672d4
rbx 0xffffffffffbadd11
rcx 0x41
rdi 0x509fd91700
rsi 0x7ffe253672d4
rbp 0x0
rsp 0x509fcbef00
r8 0x0
r9 0x8ac
r10 0x0
r11 0x509fe3f430
r12 0x7ffe29330000
r13 0x7ffe253610e8
r14 0xc000007a
r15 0x7ffe25365c70
rip 0x50c79a0000
rflags 0x10206
cs 0x33
fs 0x53
gs 0x2b```
My PS profile:
$PSDefaultParameterValues[“Out-File:Encoding”] = “utf8” $MaximumHistoryCount = 1000;
Import-Module posh-git Import-Module oh-my-posh Set-PoshPrompt -Theme agnoster Set-Location C:\repos
Environment
- Oh my Posh version: v3.13.0
- Theme: agnoster
- Operating System: Windows 10 build 10240
- Shell: Powershell
- Terminal: Allacritty (the same thing happens in standard PS 7 terminal)
- Go version: go version go1.15.2 windows/amd64 (not sure if this matters)
Steps to Reproduce
- Install posh git and oh my posh.
- Update config file.
- Start terminal.
Expected behavior: [What you expected to happen] Terminal starts without issues
Actual behavior: [What actually happened] Oh my pish throws an exception
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 42 (25 by maintainers)
Commits related to this issue
- refactor: user env for user name relates to #55 — committed to JanDeDobbeleer/oh-my-posh by JanDeDobbeleer 4 years ago
- refactor: user env for user name relates to #55 — committed to JanDeDobbeleer/oh-my-posh by JanDeDobbeleer 4 years ago
- refactor: user env for user name relates to #55 — committed to JanDeDobbeleer/oh-my-posh by JanDeDobbeleer 4 years ago
- fix: remove user.current() relates to #55 — committed to JanDeDobbeleer/oh-my-posh by JanDeDobbeleer 4 years ago
- fix: remove user.current() relates to #55 — committed to JanDeDobbeleer/oh-my-posh by JanDeDobbeleer 4 years ago
This may be issue from ConHost. Alacritty use ConPty from Conhost. WezTerm and Windows Terminal is using ConPty from OpenConsol. I guess this issue is not happenned in WezTerm and Windows Terminal. You can see this issue on Alacritty https://github.com/alacritty/alacritty/issues/4794 .
Without enabled a theme, just import the module I get this
If I enable a theme, for example
Set-PoshPrompt -Theme paradoxI get this:So no error but it also stop posh-git from loading and prompt is just PS>
Let’s just say I’m intrigued as to why this doesn’t work.
Yes, I already had that setting enabled, it made no difference to me.
I know what’s happening. On Windows we need to set the output mode to interpret ANSI. That’s what’s failing here. I have one thing I can try, but no guarantee.
Same thing seems to be happening with 3.14.4 (I know it has got the fix for this issue but I tried for the sake of completeness).
Also, my version output:
Will do first thing tomorrow.
I’ve installed the latest version 7 about a week go.
@kwmlodozeniec stay tuned for
3.14.1