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

Error: unknown command "fatal" for "oh-my-posh" #3495

Closed FlorianLoch closed 1 year ago

FlorianLoch commented 1 year ago

Code of Conduct

What happened?

Since today I am observing this behaviour running 14.2.8

Rendering the prompt works but these lines get printed before:

Error: unknown command "fatal" for "oh-my-posh"
Run 'oh-my-posh --help' for usage.
(eval):4: no matches found: [running]:
(eval):7: no matches found: github.com/jandedobbeleer/oh-my-posh/src/engine.(*Segment).SetEnabled.func1

Full example:

00:07:45 ❯ oh-my-posh version
14.2.8
Error: unknown command "fatal" for "oh-my-posh"
Run 'oh-my-posh --help' for usage.
(eval):4: no matches found: [running]:
(eval):7: no matches found: github.com/jandedobbeleer/oh-my-posh/src/engine.(*Segment).SetEnabled.func1

Theme

# yaml-language-server: $schema=https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json
final_space: true
version: 2
blocks:
  # Add a blank line for separation
  - alignment: left
    type: prompt
    segments:
      - type: text
        style: plain
  - alignment: left
    newline: true
    type: prompt
    segments:
      - background: '#29315A'
        foreground: '#3EC669'
        leading_diamond: 
        properties:
          style: mixed
        style: diamond
        template:  {{ .Path }}
        trailing_diamond: 
        type: path
      - type: git
        background: '#29315A'
        foreground: '#43CCEA'
        foreground_templates:
          - '{{ if or (.Working.Changed) (.Staging.Changed) }}#FF9248{{ end }}'
          - '{{ if and (gt .Ahead 0) (gt .Behind 0) }}#ff4500{{ end }}'
          - '{{ if gt .Ahead 0 }}#B388FF{{ end }}'
          - '{{ if gt .Behind 0 }}#B388FF{{ end }}'
        leading_diamond: ' '
        properties:
          branch_max_length: 25
          fetch_stash_count: true
          fetch_status: true
          fetch_upstream_icon: true
        style: diamond
        template: ' {{ .UpstreamIcon }}{{ .Ref }}{{if .BranchStatus }} {{ .BranchStatus }}{{ end }}{{ if .Working.Changed }} {{ .Working.String }}{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Staging.Changed }}  {{ .Staging.String }}{{ end }}{{ if gt .StashCount 0 }}  {{ .StashCount }}{{ end }} '
        trailing_diamond: 
      - type: executiontime
        leading_diamond: ' '
        background: 'yellow'
        foreground: 'black'
        properties:
          style: austin
          threshold: 1000
        style: diamond
        template: '{{ .FormattedMs }}'
        trailing_diamond: 
  - alignment: right
    type: prompt
    segments:
      - background: '#29315A'
        foreground: '#E4F34A'
        leading_diamond: ' '
        properties:
          fetch_version: false
        style: diamond
        template: >-
           {{ if .Error }}{{ .Error }}{{ else }}{{ if .Venv }}{{ .Venv }} {{
          end }}{{ .Full }}{{ end }}
        trailing_diamond: 
        type: python
      - type: go
        background: '#29315A'
        foreground: '#7FD5EA'
        leading_diamond: ' '
        properties:
          fetch_version: true
          parse_mod_file: true
        style: diamond
        template: "\u202D\uFCD1 {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }}"
        trailing_diamond: 
      - type: kubectl
        background: 'blue'
        foreground: 'white'
        leading_diamond: ' '
        properties:
          fetch_version: true
          parse_mod_file: true
        style: diamond
        # Do not need the cluster to be shown - but would be: {{ .Cluster }}
        template: "\uFD31 {{ if .Namespace }}{{ .Namespace }}{{ else }}default{{ end }}"
        trailing_diamond: 
      - type: node
        background: '#29315A'
        foreground: '#42E66C'
        leading_diamond: ' '
        properties:
          fetch_version: false
        style: diamond
        template: >-
          {{ if .PackageManagerIcon }}{{ .PackageManagerIcon }} {{ end }}{{
          .Full }}
        trailing_diamond: 
      - background: '#29315A'
        foreground: '#E64747'
        leading_diamond: ' '
        properties:
          fetch_version: false
        style: diamond
        template: {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }}
        trailing_diamond: 
        type: ruby
      - background: '#29315A'
        foreground: '#E64747'
        leading_diamond: ' '
        properties:
          fetch_version: false
        style: diamond
        template: {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }}
        trailing_diamond: 
        type: java
      - background: '#29315A'
        foreground: '#9B6BDF'
        leading_diamond: ' '
        properties:
          fetch_version: false
        style: diamond
        template: '{{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }} '
        trailing_diamond: 
        type: julia
      - type: php
        style: diamond
        foreground: '#ffffff'
        background: '#4063D8'
        leading_diamond: ' '
        properties:
          fetch_version: false
        template: ' {{ .Full }} '
        trailing_diamond: 
  - alignment: left
    type: prompt
    newline: true
    segments:
      - type: text
        # background: '#29315A'
        foreground_templates:
          - "{{ if ne .Code 0 }}#e24846{{ else }}#46e27f{{ end }}"
        # leading_diamond: 
        style: diamond
        template: '❯'
        # trailing_diamond: 
transient_prompt:
  type: "text"
  foreground: "#bba4db"
  template: '{{ now | date "15:04:05" }} ❯ '

What OS are you seeing the problem on?

macOS

Which shell are you using?

zsh

Log output

oh-my-posh fatal error rendering go segment:runtime error: invalid memory address or nil pointer dereference

goroutine 1 [running]:
runtime/debug.Stack()
    /opt/homebrew/Cellar/go/1.19.5/libexec/src/runtime/debug/stack.go:24 +0x64
github.com/jandedobbeleer/oh-my-posh/src/engine.(*Segment).SetEnabled.func1()
    /private/tmp/oh-my-posh-20230214-96808-1rqizjj/oh-my-posh-14.2.8/src/engine/segment.go:450 +0x40
panic({0x1054b6260, 0x105f80950})
    /opt/homebrew/Cellar/go/1.19.5/libexec/src/runtime/panic.go:884 +0x204
github.com/jandedobbeleer/oh-my-posh/src/segments.(*Golang).getVersion(0x140004b3340)
    /private/tmp/oh-my-posh-20230214-96808-1rqizjj/oh-my-posh-14.2.8/src/segments/golang.go:55 +0xf8
github.com/jandedobbeleer/oh-my-posh/src/segments.(*language).setVersion(0x140004b3340)
    /private/tmp/oh-my-posh-20230214-96808-1rqizjj/oh-my-posh-14.2.8/src/segments/language.go:177 +0x80
github.com/jandedobbeleer/oh-my-posh/src/segments.(*language).Enabled(0x140004b3340)
    /private/tmp/oh-my-posh-20230214-96808-1rqizjj/oh-my-posh-14.2.8/src/segments/language.go:134 +0x374
github.com/jandedobbeleer/oh-my-posh/src/segments.(*Golang).Enabled(0x1055839c0?)
    /private/tmp/oh-my-posh-20230214-96808-1rqizjj/oh-my-posh-14.2.8/src/segments/golang.go:59 +0x20
github.com/jandedobbeleer/oh-my-posh/src/engine.(*Segment).SetEnabled(0x14000582d00, {0x1055839c0, 0x14000225f10})
    /private/tmp/oh-my-posh-20230214-96808-1rqizjj/oh-my-posh-14.2.8/src/engine/segment.go:470 +0x128
github.com/jandedobbeleer/oh-my-posh/src/engine.(*Block).Debug(0x140000dea50)
    /private/tmp/oh-my-posh-20230214-96808-1rqizjj/oh-my-posh-14.2.8/src/engine/block.go:217 +0x118
github.com/jandedobbeleer/oh-my-posh/src/engine.(*Engine).PrintDebug(0x1400044fcb8, {0x1052c2c86?, 0x0?, 0x105fb2200?}, {0x105412948?, 0x0?})
    /private/tmp/oh-my-posh-20230214-96808-1rqizjj/oh-my-posh-14.2.8/src/engine/engine.go:266 +0x4c8
github.com/jandedobbeleer/oh-my-posh/src/cli.glob..func7(0x105f8c8c0?, {0x105fe2ab8?, 0x0?, 0x0?})
    /private/tmp/oh-my-posh-20230214-96808-1rqizjj/oh-my-posh-14.2.8/src/cli/debug.go:47 +0x2bc
github.com/spf13/cobra.(*Command).execute(0x105f8c8c0, {0x105fe2ab8, 0x0, 0x0})
    /Users/floch/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:920 +0x5b0
github.com/spf13/cobra.(*Command).ExecuteC(0x105f8d160)
    /Users/floch/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:1044 +0x35c
github.com/spf13/cobra.(*Command).Execute(...)
    /Users/floch/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:968
github.com/jandedobbeleer/oh-my-posh/src/cli.Execute({0x105412948?, 0x140000021a0?})
    /private/tmp/oh-my-posh-20230214-96808-1rqizjj/oh-my-posh-14.2.8/src/cli/root.go:41 +0x68
main.main()
    /private/tmp/oh-my-posh-20230214-96808-1rqizjj/oh-my-posh-14.2.8/src/main.go:10 +0x2c
FlorianLoch commented 1 year ago

Well, killing the terminal and tmux resolved the issue - so most likely not related to oh-my-posh. Sorry!

JanDeDobbeleer commented 1 year ago

@FlorianLoch let me know if it happens again, shouldn't do that.

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