JanDeDobbeleer / oh-my-posh

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

Azure Subscription not showing in prompt #3230

Closed floushee closed 1 year ago

floushee commented 1 year ago

Code of Conduct

What happened?

I have the following prompt config:

{
       "type": "rprompt",
       "alignment": "right",
       "segments": [
        {
            "background": "#000000",
            "foreground": "#929292",
            "powerline_symbol": "\ue0b0",
            "properties": {
              "display_id": true,
              "display_name": true,
              "info_separator": " @ ",
              "source": "pwsh"
            },
            "style": "diamond",
            "template": " \uFD03 {{ .Name  }}",
            "type": "az"
          }
       ] 
    }

When I run the debug mode it gives me the following error:

2022/12/21 09:18:23 getenv duration: 0s, args: AZ_ENVIRONMENT_NAME
2022/12/21 09:18:23 debug: getenv

2022/12/21 09:18:23 getenv duration: 0s, args: AZ_USER_NAME
2022/12/21 09:18:23 debug: getenv

2022/12/21 09:18:23 getenv duration: 0s, args: AZ_SUBSCRIPTION_ID
2022/12/21 09:18:23 debug: getenv

2022/12/21 09:18:23 getenv duration: 0s, args: AZ_ACCOUNT_NAME
2022/12/21 09:18:23 hasCommand duration: 2.0382ms, args: az
2022/12/21 09:18:23 getRuntimeGOOS duration: 0s, args:
2022/12/21 09:18:23 error: runCommand
cmd.Start() failed with 'exec: "az.exe": executable file not found in %PATH%'`

It looks like the source property is ignored because it is still trying to use the Azure CLI to get the information? I do have the Azure CLI installed but there is not a exe as it is python based (only have a az.cmd).

I tried to upgrade everything to the latest versions and it also did not fix the issue. Any ideas?

Theme

{ "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json", "blocks": [ { "alignment": "left", "segments": [ { "background": "#222725", "foreground": "#ffffff", "leading_diamond": "\ue0b6", "powerline_symbol": "\ue0b0", "properties": { "style": "folder" }, "style": "diamond", "template": " \ue5ff {{ .Path }} ", "trailing_diamond": "\ue0b0", "type": "path" }, { "background": "#E09F3E", "foreground": "#ffffff", "powerline_symbol": "\ue0b0", "properties": { "fetch_stash_count": true, "fetch_status": true, "fetch_upstream_icon": true }, "style": "powerline", "template": " {{ .HEAD }} {{ .BranchStatus }}{{ if .Working.Changed }} \uf044 {{ .Working.String }}{{ end }}{{ if and (.Staging.Changed) (.Working.Changed) }} |{{ end }}{{ if .Staging.Changed }} \uf046 {{ .Staging.String }}{{ end }}{{ if gt .StashCount 0}} \uf692 {{ .StashCount }}{{ end }}{{ if gt .WorktreeCount 0}} \uf1bb {{ .WorktreeCount }}{{ end }} ", "type": "git" }, { "background": "#15846E", "foreground": "#ffffff", "powerline_symbol": "\ue0b0", "properties": { "fetch_version": true }, "style": "powerline", "template": " \ue70c {{ if .Unsupported }}\uf071{{ else }}{{ .Full }}{{ end }} ", "type": "dotnet" } ], "type": "prompt" }, { "type": "rprompt", "alignment": "right", "segments": [ { "background": "#000000", "foreground": "#929292", "powerline_symbol": "\ue0b0", "properties": { "display_id": true, "display_name": true, "info_separator": " @ ", "source": "first_match" }, "style": "diamond", "template": " \uFD03 {{ .Name }}", "type": "az" } ] } ], "final_space": true, "version": 2 }

What OS are you seeing the problem on?

Windows

Which shell are you using?

powershell

Log output

2022/12/21 09:18:23 debug: getenv
C:\Users\domin\AppData\Local
2022/12/21 09:18:23 getenv duration: 0s, args: LOCALAPPDATA
2022/12/21 09:18:23 getCachePath duration: 0s, args:
2022/12/21 09:18:23 getArgs duration: 0s, args:
2022/12/21 09:18:23 getArgs duration: 0s, args:
2022/12/21 09:18:23 getShellName duration: 0s, args:
2022/12/21 09:18:23 debug: getenv

2022/12/21 09:18:23 getenv duration: 0s, args: OMP_CACHE_DISABLED
2022/12/21 09:18:23 isRunningAsRoot duration: 0s, args:
2022/12/21 09:18:23 getcwd duration: 0s, args:
2022/12/21 09:18:23 getPathSeperator duration: 0s, args:
2022/12/21 09:18:23 getPathSeperator duration: 0s, args:
2022/12/21 09:18:23 getShellName duration: 0s, args:
2022/12/21 09:18:23 getCurrentUser duration: 0s, args:
2022/12/21 09:18:23 getHostName duration: 0s, args:
2022/12/21 09:18:23 getcwd duration: 0s, args:
2022/12/21 09:18:23 getcwd duration: 0s, args:
2022/12/21 09:18:23 getArgs duration: 0s, args:
2022/12/21 09:18:23 getcwd duration: 0s, args:
2022/12/21 09:18:23 getRuntimeGOOS duration: 0s, args:
2022/12/21 09:18:23 getRuntimeGOOS duration: 0s, args:
2022/12/21 09:18:23 getPathSeperator duration: 0s, args:
2022/12/21 09:18:23 getPathSeperator duration: 0s, args:
2022/12/21 09:18:23 getPathSeperator duration: 0s, args:
2022/12/21 09:18:23 getRuntimeGOOS duration: 0s, args:
2022/12/21 09:18:23 getcwd duration: 0s, args:
2022/12/21 09:18:23 getRuntimeGOOS duration: 0s, args:
2022/12/21 09:18:23 hasCommand duration: 9.2864ms, args: git.exe
2022/12/21 09:18:23 getcwd duration: 0s, args:
2022/12/21 09:18:23 error: hasParentFilePath
CreateFile C:\.git: The system cannot find the file specified.
2022/12/21 09:18:23 hasParentFilePath duration: 508.4µs, args: .git
2022/12/21 09:18:23 getcwd duration: 0s, args:
2022/12/21 09:18:23 getcwd duration: 0s, args:
2022/12/21 09:18:23 getcwd duration: 0s, args:
2022/12/21 09:18:23 debug: getenv

2022/12/21 09:18:23 getenv duration: 0s, args: AZ_ENVIRONMENT_NAME
2022/12/21 09:18:23 debug: getenv

2022/12/21 09:18:23 getenv duration: 0s, args: AZ_USER_NAME
2022/12/21 09:18:23 debug: getenv

2022/12/21 09:18:23 getenv duration: 0s, args: AZ_SUBSCRIPTION_ID
2022/12/21 09:18:23 debug: getenv

2022/12/21 09:18:23 getenv duration: 0s, args: AZ_ACCOUNT_NAME
2022/12/21 09:18:23 hasCommand duration: 2.0382ms, args: az
2022/12/21 09:18:23 getRuntimeGOOS duration: 0s, args:
2022/12/21 09:18:23 error: runCommand
cmd.Start() failed with 'exec: "az.exe": executable file not found in %PATH%'
2022/12/21 09:18:23 runCommand duration: 12.6721ms, args: az.exe account show
JanDeDobbeleer commented 1 year ago

@floushee doe you have $env:POSH_AZURE_ENABLED = $true set in your $PROFILE after initialising oh-my-posh? See here.

floushee commented 1 year ago

Yes, here is the part of my $PROFILE:

oh-my-posh --init --shell pwsh --config "...." | Invoke-Expression
$env:POSH_AZURE_ENABLED = $true

Any other ideas? Anything how I could trigger more logs or something?

What interests me is, that although I have set source to be pwsh it still tries to run the az command.

JanDeDobbeleer commented 1 year ago

@floushee what version of oh-my-posh are you on? Could be "old".

floushee commented 1 year ago

Cool thanks. That did the trick. I updated my powershell modules and thought that that might upgrade oh my posh too :)

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.