spaceship-prompt: Async section are not rendering

Is there an existing issue for this?

  • Yes, I have searched the existing issues
  • Yes, I have checked troubleshooting page

The problem

The rendering of async sections such as Git is not reliable and frequently fails to render: image

It seems to be random with no discernible pattern. The async indicator (…) also never disappears, it is always there, and the async count is always 23 when enabled.

Relevant Zsh configuration

(Loaded with Antibody)
source $dotfilesZsh/zsh_plugins.sh
SPACESHIP_PROMPT_ADD_NEWLINE="false" # disable newline before prompt

Contents of zsh_plugins.sh:
source /home/james/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-spaceship-prompt-SLASH-spaceship-prompt/async.zsh
source /home/james/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-spaceship-prompt-SLASH-spaceship-prompt/spaceship.zsh
fpath+=( /home/james/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-spaceship-prompt-SLASH-spaceship-pro

What is version of Spaceship are you using?

v4.2.5

What is version of Zsh are you using?

5.8.1

What operation system are you running?

Fedora Linux 36 (Cinnamon)

Do you use any Zsh framework or plugin manager?

Antibody

Which terminal emulator do you use?

Gnome Terminal (v3.44.1)

Additional information

No response

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 12
  • Comments: 51 (22 by maintainers)

Commits related to this issue

Most upvoted comments

Interesting. I guess maybe async worker fails sometimes. Maybe we can fix that be restarting it.

If you’re struggling with the async rendering, you can try disabling it for now, by:

SPACESHIP_PROMPT_ASYNC=false

@dmint789 unfortunately I can’t give exact ETA for the fix of this problem. I understand that you really want this to be fixed, but try to understand that I’m maintaining this project in my free time, besides my daytime job, missile strikes and electricity outages during the war.

Any help with this issue is highly appreciated. Thanks for understanding!

Hey all, I spent some hours on this today because I find it quite annoying.

I think I was able to pinpoint the issue to zpty: it seems that if the command is too quick, it doesn’t properly return it.

This also explains because in this issue we have seen many different prompts having the issue: at the end of the day, it is up to how long a command takes, and there are so many variables…

On my PC, I noticed that the threshold is around 50ms: if any command takes less than that, then it is not properly returned by zpty.

As a temporary workaround, I set a sleep 0.05 in the _async_job() function.

diff --git a/async.zsh b/async.zsh
index de13e75..8a8a981 100644
--- a/async.zsh
+++ b/async.zsh
@@ -28,6 +28,8 @@ _async_job() {
        # Disable xtrace as it would mangle the output.
        setopt localoptions noxtrace
 
+       sleep 0.05
+
        # Store start time for job.
        float -F duration=$EPOCHREALTIME

This addresses the problem for me, although now the prompt is way slower (0.05s of delay for each section).

I wonder if the root cause is a bug in zpty, or the problem is that spaceship is using one worker for everything, and results are so quick that begin arriving before all the inputs have been inserted, mangling the results… Probably, something to try would be using a different worker for each section.

Hope it can be useful!

When should we expect async loading to be fixed?

@dmint789 unfortunately I can’t give exact ETA for the fix of this problem. I understand that you really want that to be fixed, but try to understand that I’m maintaining this project in my free time, besides my daytime job, missile strikes and electricity outages due to war.

Any help with this issue is highly appreciated. Thanks for understanding!

Dude, seriously… be careful out there. We completely understand.

Okay, I’ve finally run into the similar problem. I got async section stuck always displaying . For me, it was resolved by removing dotnet section.

UPD: Though, removing only dotnet section doesn’t help. Seems like the problem is with something else, still digging.

Issue still persist for me

Hey everyone, check v4.6.0 version. It resolved the issue with always displaying ... for me. Let me know if that helps.

FTR Fedora still has this problem. I was showing the theme to a newbie on a clean F38 install with omz and all we ever saw was ...

I guess that’s because Spaceship doesn’t handle worker failure properly. We have a todo-task for it here:

https://github.com/spaceship-prompt/spaceship-prompt/blob/master/lib/core.zsh#L61-L67

We should implement worker error handling, something like pure prompt has:

https://github.com/sindresorhus/pure/blob/main/pure.zsh#L507-L530

I also have the issue as @jamerst. I have the same setup, Fedora Workstation, Gnome Termnial, ZSH version.

I have disabled async untill the main issue is found.

I found a solution for this, I hope it works for you also

in .zshrc add this which you can find in the docs here

SPACESHIP_PROMPT_ORDER=(
  time           # Time stamps section
  user           # Username section
  dir            # Current directory section
  host           # Hostname section
  git            # Git section (git_branch + git_status)
  hg             # Mercurial section (hg_branch  + hg_status)
  package        # Package version
  node           # Node.js section
  bun            # Bun section
  deno           # Deno section
  ruby           # Ruby section
  python         # Python section
  elm            # Elm section
  elixir         # Elixir section
  xcode          # Xcode section
  swift          # Swift section
  golang         # Go section
  perl           # Perl section
  php            # PHP section
  rust           # Rust section
  haskell        # Haskell Stack section
  scala          # Scala section
  kotlin         # Kotlin section
  java           # Java section
  lua            # Lua section
  dart           # Dart section
  julia          # Julia section
  crystal        # Crystal section
  docker         # Docker section
  docker_compose # Docker section
  aws            # Amazon Web Services section
  gcloud         # Google Cloud Platform section
  azure          # Azure section
  venv           # virtualenv section
  conda          # conda virtualenv section
  dotnet         # .NET section
  ocaml          # OCaml section
  vlang          # V section
  zig            # Zig section
  purescript     # PureScript section
  erlang         # Erlang section
  kubectl        # Kubectl context section
  ansible        # Ansible section
  terraform      # Terraform workspace section
  pulumi         # Pulumi stack section
  ibmcloud       # IBM Cloud section
  nix_shell      # Nix shell
  gnu_screen     # GNU Screen section
  exec_time      # Execution time
  async          # Async jobs indicator
  line_sep       # Line break
  battery        # Battery level and status
  jobs           # Background jobs indicator
  exit_code      # Exit code section
  sudo           # Sudo indicator
  char           # Prompt character
)

and then delete everything you don’t need. for me it became like this

SPACESHIP_PROMPT_ORDER=(
  time           # Time stamps section
  user           # Username section
  dir            # Current directory section
  host           # Hostname section
  git            # Git section (git_branch + git_status)
  package        # Package version
  node           # Node.js section
  bun            # Bun section
  python         # Python section
  rust           # Rust section
  docker         # Docker section
  docker_compose # Docker section
  venv           # virtualenv section
  exit_code      # Exit code section
  sudo           # Sudo indicator
)

And also don’t forget to remove all plugins in plugins variable in .zshrc that you don’t need for me I made it like this plugins=(git zsh-autosuggestions zsh-syntax-highlighting) and don’t forget also to source ~/.zshrc

@KyleOndy if you have old async.zsh.zwc cache file, it needs to be removed, otherwise it may not work.

Setting the $SPACESHIP_DIR_TRUNC_REPO var to false was enough for me to bypass the issue.

spaceship v4.10.0 - zsh 5.8.1

The same issue still exists in v4.6.0 for me. Several sections are always blocked by dir, while others don’t. Guess it is related to the running speed.

My workaround is to disable async for those slow sections, such as:

SPACESHIP_RUBY_ASYNC=false

it’s still the same for me: dir, venv and python are “blocking” the terrraform section 😢

Linux mint 20.3 una alacritty 0.10.1 tmux 3.3a zsh 5.9 (x86_64-pc-linux-gnu)

Hopefully this PR #1246 will help to partly resolve this problem.

Same issue as @anoduck here.

Not sure if this is related, but it sounds like they might be akin to one another. I just updated via antigen, and received something like async worker not found: spaceship.

Disabling async via the above command, stopped the error. It was extremely annoying there for a moment.