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

Text segment generates "text property not defined" on Windows #1591

Closed janegilring closed 2 years ago

janegilring commented 2 years ago

Code of Conduct

What happened?

I was planning to create a theme for use cross-platform (Linux, macOS, Windows).

While it works fine on macOS: image

On Windows, both text segments fails: image

Are there any limitations with regards to the text segment on Windows?

Theme

{ "final_space": true, "console_title": true, "console_title_style": "folder", "blocks": [ { "type": "prompt", "alignment": "left", "horizontal_offset": 0, "vertical_offset": 0, "segments": [ { "type": "os", "style": "plain", "foreground": "#26C6DA", "background": "#546E7A", "properties": { "postfix": " \uE0B1" } }, { "type": "text", "style": "plain", "foreground": "#E06C75", "properties": { "prefix": "", "template": " {{ .Host }}" } }, { "type":"sysinfo", "powerline_symbol": "", "foreground": "#ffffff", "background": "#8f43f3", "invert_powerline": true, "properties": { "prefix": " \uf85a ", "postfix": "% ", "precision": 2, "template":"{{ round .PhysicalPercentUsed .Precision }}" }, "style":"powerline" }, { "type": "battery", "style": "powerline", "powerline_symbol": "\uE0B0", "foreground": "#193549", "background": "#ffeb3b", "background_templates": [ "{{if eq \"Charging\" .State.String}}#40c4ff{{end}}", "{{if eq \"Discharging\" .State.String}}#ff5722{{end}}", "{{if eq \"Full\" .State.String}}#4caf50{{end}}" ], "properties": { "discharging_icon": "\uE231 ", "charging_icon": "\uE234 ", "charged_icon": "\uE22F ", "postfix": "\uF295 ", "template": "{{ if not .Error }}{{.Icon}}{{.Percentage}}{{ end }}" } }, { "type": "path", "style": "powerline", "powerline_symbol": "", "invert_powerline": false, "foreground": "#100e23", "background": "#91ddff", "leading_diamond": "", "trailing_diamond": "", "properties": { "style": "folder", "prefix": "\uF115 ", "postfix": " " } }, { "type": "git", "style": "powerline", "powerline_symbol": "", "invert_powerline": false, "foreground": "#193549", "background": "#fffb38", "leading_diamond": "", "trailing_diamond": "", "properties": { "display_status": true, "display_stash_count": true, "display_upstream_icon": true } }, { "type": "dotnet", "style": "powerline", "powerline_symbol": "", "invert_powerline": false, "foreground": "#ffffff", "background": "#6CA35E", "leading_diamond": "", "trailing_diamond": "", "properties": { "display_version": true, "prefix": "  " } }, { "type": "root", "style": "powerline", "powerline_symbol": "", "invert_powerline": false, "foreground": "#ffffff", "background": "#ffff66", "leading_diamond": "", "trailing_diamond": "", "properties": null }, { "type": "exit", "style": "powerline", "powerline_symbol": "", "invert_powerline": false, "foreground": "#ffffff", "background": "#2e9599", "leading_diamond": "", "trailing_diamond": "", "properties": { "always_enabled": true, "color_background": true, "display_exit_code": false, "error_color": "#f1184c", "prefix": " " } }, { "type": "executiontime", "style": "powerline", "powerline_symbol": "\uE0B0", "foreground": "#ffffff", "background": "#8800dd", "properties": { "threshold": 500, "style": "austin", "prefix": " <#fefefe>\ufbab</> " } }, { "type": "newline" }, { "type": "text", "style": "plain", "properties": { "prefix": "\n", "template": "PS >" } } ] } ] }

What OS are you seeing the problem on?

Windows

Which shell are you using?

powershell

Log output

The command seems to hang at this stage:

Write-PoshDebug (PowerShell)
Loading personal and system profiles took 4956ms.
JanDeDobbeleer commented 2 years ago

@janegilring could it be you need to update your Windows version? As that error is a bit old.

janegilring commented 2 years ago

@JanDeDobbeleer Good point, sorry for not checking that first

Windows: 6.1.0 macOS: 6.48.0

After upgrading the version on the Windows machine to 6.49.2, I got the following when re-launching pwsh:

Updating oh-my-posh executable to 6.49.2
Downloading oh-my-posh themes for 6.49.2
WARNING: [11:00:49] 'Functions.ps1' Failed to invoke script! Error: Program 'oh-my-posh.exe' failed to run: StandardOutputEncoding is only supported when standard output is redirected.At C:\Users\janring.CRAYON\Documents\PowerShell\Modules\oh-my-posh\6.49.2\oh-my-posh.psm1:154 char:6
+     (& $poshCommand --init --shell=pwsh --config="$config") | Invoke- …
+      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.

Also got a popup from Windows Defender. Are there any known issues regarding this?

Update: Tried to add an exclusion for oh-my-posh.exe using Add-MpPreference -ExclusionPath. However, even no error is returned the setting is not effective when checking Get-MpPreference. Seems like company policies is preventing this. Kind of strange that the previous version was allowed, but I suppose there are some kind of signature match.

JanDeDobbeleer commented 2 years ago

@janegilring can you install using winget in that case? Not much we can do to work around that.

janegilring commented 2 years ago

@JanDeDobbeleer I tried, but unfortunately both winget and manual download was caught by Defender.

Will try to setup the same theme on a standalone Windows machine to test the original issue in this thread.

janegilring commented 2 years ago

It works perfectly fine on another Windows machine where Defender is not blocking the executable - including the rendering of the text segment.

PS: If some way of sponsorship is setup in order to cover costs for signing certificates, I`d defintiely chime in. Keep up the good work 👏

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