starship: Starship shell initialization mismatch with binary causes errors

Bug Report

I couldn’t to reproduce same error after ran tmux kill-server; pkill -TERM tmux command and re-enter in tmux. It’s the first time I got this error, any ideas?

Current Behavior

$ cat ~/.config/starship.toml | pbcopy
error: Found argument '0' which wasn't expected, or isn't valid in this context

USAGE:
    starship prompt [OPTIONS]

For more information try --help

Expected Behavior

It should work?

Additional context/Screenshots

Screen Shot 2022-02-02 at 16 09 47

Possible Solution

Exit the tmux.

Environment

  • Starship version: 1.2.1
  • Shell type: zsh
  • Shell version: zsh 5.8 (x86_64-apple-darwin20.1.0)
  • Shell plugin manager: oh-my-zsh
  • Terminal emulator: iTerm 3.4.14
  • Operating system: macOS 12.1

Relevant Shell Configuration

# Too long to fit in here

Starship Configuration

[kubernetes]
format = '[$symbol$context( \($namespace\))]($style) in '
disabled = false
symbol = '☸ '

[kubernetes.context_aliases]
"dev.local.cluster.k8s" = 'dev'

[gcloud]
disabled = true

[git_branch]
always_show_remote = true

[git_state]
format = '[\($state( $progress_current of $progress_total )\)]($style) '

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 20 (10 by maintainers)

Most upvoted comments

Okay, based on what I’m seeing in this thread so far, this is most likely going to be an issue if the following is true:

  • You use zsh
  • You dumped your starship initialization to disk at some point (whether using znap eval, redirecting the output of starship init zsh --print-full-init, or something else)
  • You upgraded starship without updating the cached init.

This will cause a mismatch between what the shell adapter passes and what starship expects, leading to the error.

The simplest way to fix this is to switch to using starship init, though this may have a few downsides depending on your use case. The second simplest is to clear your cache file (e.g. regenerate it or by deleting the file from $XDG_CACHE_HOME/zsh-snap/eval), though this will not prevent future incompatibilities from occurring.

I ran into this one as well when running any pipe

eg.

$ ls | grep hello

error: Found argument '1' which wasn't expected, or isn't valid in this context                                                                                 

USAGE:
    starship prompt [OPTIONS]

For more information try --help

Environment

Starship version: 1.3.0 Shell: zsh 5.8.1 (arm-apple-darwin21.3.0) Shell plugin manager: znap 22.01.21 Terminal emulator: kitty 0.24.2 Operating system: macOS 12.2.1

Starship configuration

command_timeout = 1000
[character]
success_symbol = "[»](bold green)"
error_symbol = "[✖](bold red)"

[aws]
disabled = true

[python]
disabled = true

[directory]
truncation_length = 8
truncate_to_repo = false
truncation_symbol = "../"

Possible Solution

In my ~/.zshrc file i was initializing starship with the following (I believe as per znap’s guide)

znap eval starship 'starship init zsh --print-full-init'

Changing too

eval "$(starship init zsh --print-full-init)"

Seems to have fixed the issue for me, so not sure what has changed/why but hopefully this helps!