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

The variable '$global:omp_global_sessionstate' cannot be retrieved because it has not been set. #2173

Closed Praful closed 2 years ago

Praful commented 2 years ago

Code of Conduct

What happened?

When I start a new shell, $error has this message:

InvalidOperation:
Line |
  99 |          if ($global:omp_global_sessionstate -ne $null) {
     |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | The variable '$global:omp_global_sessionstate' cannot be retrieved because it has not been set.

Then as I continue to use PowerShell, $error gets appended with the same error message.

There are some suggestions to avoid this error message here.

Theme

{
  "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
  "blocks": [
    {
      "alignment": "left",
      "segments": [
        {
          "background": "#ffe9aa",
          "foreground": "#100e23",
          "powerline_symbol": "\ue0b0",
          "style": "powerline",
          "template": " \uf0e7 ",
          "type": "root"
        },
        {
          "background": "#005fff",
          "foreground": "#ffffff",
          "powerline_symbol": "\ue0b0",
          "properties": {
            "style": "full"
          },
          "style": "powerline",
          "template": " {{ .Path }} ",
          "type": "path"
        },
        {
          "background": "#ECEC81",
          "foreground": "#193549",
          "powerline_symbol": "\ue0b0",
          "style": "powerline",
          "template": " {{ .HEAD }}{{ if .Staging.Changed }}<#FF6F00> \uf046 {{ .Staging.String }}</>{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Working.Changed }} \uf044 {{ .Working.String }}{{ end }}{{ if gt .StashCount 0 }} \uf692 {{ .StashCount }}{{ end }} ",
          "type": "git"
        },
        {
          "background": "#95ffa4",
          "foreground": "#100e23",
          "powerline_symbol": "\ue0b0",
          "properties": {
            "style": "austin",
            "threshold": 500
          },
          "style": "powerline",
          "template": " <#508858>\ufbab</> {{ .FormattedMs }} ",
          "type": "executiontime"
        },
        {
          "background": "#ff8080",
          "foreground": "#193549",
          "powerline_symbol": "\ue0b0",
          "style": "powerline",
          "template": " <#FFFFFF>\u2718 </>{{ if gt .Code 0 }}\uf00d {{ .Meaning }}{{ else }}\uf42e{{ end }} ",
          "type": "exit"
        }
      ],
      "type": "prompt"
    },
    {
      "alignment": "left",
      "newline": true,
      "segments": [
        {
          "foreground": "#F7F759",
          "style": "plain",
          "template": "\u276f ",
          "type": "text"
        }
      ],
      "type": "prompt"
    }
  ],
  "version": 2
}

What OS are you seeing the problem on?

Windows

Which shell are you using?

powershell

Log output

❯ oh-my-posh debug

Version: 7.63.0

Segments:

ConsoleTitle(false)  -   1 ms -
root(false)          -   0 ms -
path(true)           -   1 ms -  C:\data
git(false)           -  27 ms -
executiontime(false) -   0 ms -
exit(false)          -   0 ms -
text(true)           -   0 ms - ❯

Run duration: 30.658ms

Cache path: C:\Users\praful\AppData\Local\oh-my-posh

Logs:

2022/04/27 16:56:41 Flags duration: 0s, args:
2022/04/27 16:56:41 Flags duration: 0s, args:
2022/04/27 16:56:41 debug: Getenv

2022/04/27 16:56:41 Getenv duration: 0s, args: OMP_CACHE_DISABLED
2022/04/27 16:56:41 Root duration: 0s, args:
2022/04/27 16:56:41 Shell duration: 0s, args:
2022/04/27 16:56:41 ErrorCode duration: 0s, args:
2022/04/27 16:56:41 IsWsl duration: 0s, args:
2022/04/27 16:56:41 debug: Pwd
C:\data
2022/04/27 16:56:41 Pwd duration: 0s, args:
2022/04/27 16:56:41 debug: Home
c:\data\LinuxHome
2022/04/27 16:56:41 PathSeparator duration: 0s, args:
2022/04/27 16:56:41 PathSeparator duration: 0s, args:
2022/04/27 16:56:41 PathSeparator duration: 0s, args:
2022/04/27 16:56:41 PathSeparator duration: 0s, args:
2022/04/27 16:56:41 PathSeparator duration: 0s, args:
2022/04/27 16:56:41 PathSeparator duration: 0s, args:
2022/04/27 16:56:41 debug: User
praful
2022/04/27 16:56:41 User duration: 0s, args:
2022/04/27 16:56:41 debug: Host
PORTEGEZ30
2022/04/27 16:56:41 Host duration: 0s, args:
2022/04/27 16:56:41 GOOS duration: 0s, args:
2022/04/27 16:56:41 TemplateCache duration: 515.4µs, args:
2022/04/27 16:56:41 debug: Pwd
C:\data
2022/04/27 16:56:41 Pwd duration: 0s, args:
2022/04/27 16:56:41 debug: Home
c:\data\LinuxHome
2022/04/27 16:56:41 GOOS duration: 0s, args:
2022/04/27 16:56:41 Root duration: 595.1µs, args:
2022/04/27 16:56:41 debug: Pwd
C:\data
2022/04/27 16:56:41 Pwd duration: 0s, args:
2022/04/27 16:56:41 debug: Home
c:\data\LinuxHome
2022/04/27 16:56:41 GOOS duration: 0s, args:
2022/04/27 16:56:41 debug: Pwd
C:\data
2022/04/27 16:56:41 Pwd duration: 0s, args:
2022/04/27 16:56:41 Flags duration: 0s, args:
2022/04/27 16:56:41 debug: Pwd
C:\data
2022/04/27 16:56:41 Pwd duration: 0s, args:
2022/04/27 16:56:41 debug: Home
c:\data\LinuxHome
2022/04/27 16:56:41 GOOS duration: 0s, args:
2022/04/27 16:56:41 GOOS duration: 0s, args:
2022/04/27 16:56:41 PathSeparator duration: 0s, args:
2022/04/27 16:56:41 GOOS duration: 0s, args:
2022/04/27 16:56:41 IsWsl duration: 0s, args:
2022/04/27 16:56:41 StackCount duration: 0s, args:
2022/04/27 16:56:41 TemplateCache duration: 0s, args:
2022/04/27 16:56:41 debug: Pwd
C:\data
2022/04/27 16:56:41 Pwd duration: 0s, args:
2022/04/27 16:56:41 debug: Home
c:\data\LinuxHome
2022/04/27 16:56:41 GOOS duration: 0s, args:
2022/04/27 16:56:41 GOOS duration: 0s, args:
2022/04/27 16:56:41 HasCommand duration: 24.8644ms, args: git.exe
2022/04/27 16:56:41 debug: Pwd
C:\data
2022/04/27 16:56:41 Pwd duration: 0s, args:
2022/04/27 16:56:41 error: HasParentFilePath
CreateFile C:\.git: The system cannot find the file specified.
2022/04/27 16:56:41 HasParentFilePath duration: 3.0348ms, args: .git
2022/04/27 16:56:41 debug: Pwd
C:\data
2022/04/27 16:56:41 Pwd duration: 0s, args:
2022/04/27 16:56:41 debug: Home
c:\data\LinuxHome
2022/04/27 16:56:41 GOOS duration: 0s, args:
2022/04/27 16:56:41 ExecutionTime duration: 0s, args:
2022/04/27 16:56:41 debug: Pwd
C:\data
2022/04/27 16:56:41 Pwd duration: 0s, args:
2022/04/27 16:56:41 debug: Home
c:\data\LinuxHome
2022/04/27 16:56:41 GOOS duration: 0s, args:
2022/04/27 16:56:41 ErrorCode duration: 0s, args:
2022/04/27 16:56:41 ErrorCode duration: 0s, args:
2022/04/27 16:56:41 debug: Pwd
C:\data
2022/04/27 16:56:41 Pwd duration: 0s, args:
2022/04/27 16:56:41 debug: Home
c:\data\LinuxHome
2022/04/27 16:56:41 GOOS duration: 0s, args:
2022/04/27 16:56:41 TemplateCache duration: 0s, args:
2022/04/27 16:56:41 debug: Getenv
C:\Users\praful\AppData\Local
2022/04/27 16:56:41 Getenv duration: 0s, args: LOCALAPPDATA
2022/04/27 16:56:41 CachePath duration: 0s, args:
JanDeDobbeleer commented 2 years ago

@Praful updating fixes the issue already. I'll make sure there's also a better implementation.

Praful commented 2 years ago

@JanDeDobbeleer thanks for the quick response and apologies for not trying the latest version before posting. It didn't seem that long ago that I installed the version I had! Good to see such rapid iterations for a great app.

$error now clean :-)

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.