romkatv / powerlevel10k

A Zsh theme
MIT License
45.69k stars 2.16k forks source link

Instant prompt output error only in tmux #2299

Closed stepanzak closed 1 year ago

stepanzak commented 1 year ago

Hi, first of all, thanks for this amazing prompt! I recently started using tmux and I noticed something weird. When I start tmux, even with no config and no plugins, I get this error:

[WARNING]: Console output during zsh initialization detected. Then long instructions follow and at the end, this:

-- console output produced during zsh initialization follows --

╭─░▒▓    ~ ············································································································· ✔  23:04:09  ▓▒░
╰─

There's just one newline, but I don't know if that is part of the error or the console output.

This happens only in tmux and when I run exec zsh or zsh after that, no error occurs. When I create a new tmux window or pane, new error happens there. Sometimes, it doesn't happen when I start tmux but alway when I create new window or pane.

At first, I thought it's caused by some of my tmux plugins, but it happens even with the default tmux config on my pc. On my Android phone with Termux, it doesn't happen, even though I have the same dotfiles here. It cannot be caused by my terminal, it happens in konsole and wezterm.

Thank you for any help or at least pointing me to where can this error come from.

romkatv commented 1 year ago

Does it happen if you remove everything from .zshrc except for powerlevel10k? Basically, your .zshrc should look like this:

source ~/.p10k.zsh
source /path/to/powerlevel10k.zsh-theme
stepanzak commented 1 year ago

I did some testing and in Arch Linux or Ubuntu docker container, this issue is not present. I created a new user on my pc and did a clean manual install of p10k here. The issue was exactly the same. I installed OS I'm running (EndeavourOS based on Arch) in a virtual machine and the issue was not there. Therefore I assume it's something with my system, but I have no clue what can it be. I am not able to reproduce it anywhere else than on my system, so I'm closing this issue as Can't repro.

romkatv commented 1 year ago

Alright. Could you answer my question though? I'm curious.

stepanzak commented 1 year ago

Sure. When I put only these two lines in my .zshrc and start tmux, nothing special happens. See the screenshot: Screenshot_20230509_200613

romkatv commented 1 year ago

So the error cannot be reproduced when your zsh config enabled just powerlevel10k? This suggest that something else in your zsh config is necessary for the error to trigger. You can try finding out what that is by enabling things one by one.

romkatv commented 1 year ago

Oh, I'm being silly. Of course you also need to add the instant prompt preamble to the two-line zshrc to check whether the error triggers then.

stepanzak commented 1 year ago

When I add the instant prompt code it causes the error. Screenshot_20230509_201205 (the tmux is horizontal-splitted)

romkatv commented 1 year ago

That's nice! The next thing to check is the other rc files. You can do it with this command:

zsh --sourcetrace -lic ''

If this shows any rc files in your home directory, delete them. If the error still reproduces after this, create ~/.zshenv with this content:

setopt no_global_rcs

Does the error reproduce then?

stepanzak commented 1 year ago

This is output of zsh --sourcetrace -lic '':

❯ zsh --sourcetrace -lic ''
+/etc/zsh/zprofile:1> <sourcetrace>
+/etc/profile:1> <sourcetrace>
+/etc/profile.d/debuginfod.sh:1> <sourcetrace>
+/etc/profile.d/dotnet.sh:1> <sourcetrace>
+/etc/profile.d/flatpak-bindir.sh:1> <sourcetrace>
+/etc/profile.d/flatpak.sh:1> <sourcetrace>
+/etc/profile.d/freetype2.sh:1> <sourcetrace>
+/etc/profile.d/gawk.sh:1> <sourcetrace>
+/etc/profile.d/gpm.sh:1> <sourcetrace>
+/etc/profile.d/jre.sh:1> <sourcetrace>
+/etc/profile.d/libreoffice-fresh.sh:1> <sourcetrace>
+/etc/profile.d/locale.sh:1> <sourcetrace>
+/etc/profile.d/PackageKit.sh:1> <sourcetrace>
+/etc/profile.d/perlbin.sh:1> <sourcetrace>
+/etc/profile.d/vte.sh:1> <sourcetrace>
+/etc/profile.d/wezterm.sh:1> <sourcetrace>
+/home/stepka/.zshrc:1> <sourcetrace>
+/home/stepka/.cache/p10k-instant-prompt-stepka.zsh:1> <sourcetrace>
+/home/stepka/.p10k.zsh:1> <sourcetrace>
+/home/stepka/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-romkatv-SLASH-powerlevel10k/powerlevel10k.zsh-theme:1> <sourcetrace>
+/home/stepka/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-romkatv-SLASH-powerlevel10k/gitstatus/gitstatus.plugin.zsh:1> <sourcetrace>
+/home/stepka/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-romkatv-SLASH-powerlevel10k/internal/p10k.zsh:1> <sourcetrace>
+/home/stepka/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-romkatv-SLASH-powerlevel10k/internal/configure.zsh:1> <sourcetrace>
+/home/stepka/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-romkatv-SLASH-powerlevel10k/internal/worker.zsh:1> <sourcetrace>
+/home/stepka/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-romkatv-SLASH-powerlevel10k/internal/parser.zsh:1> <sourcetrace>
+/home/stepka/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-romkatv-SLASH-powerlevel10k/internal/icons.zsh:1> <sourcetrace>

I wasn't sure what should I delete, so I created the .zshenv file as you suggested and now when I start tmux there's no error! I guess one of the files listed is responsible of that then, right?

stepanzak commented 1 year ago

I found out this is caused by /etc/profile.d/wezterm.sh. github.com/wez/wezterm/blob/main/assets/shell-integration/wezterm.sh I will open an issue in Wezterm's repo. Thanks for your help and your patience @romkatv !

romkatv commented 1 year ago

It's not a bug in wezterm, so no need to report this. I'll take a look at the file you linked tomorrow or later in the week.

stepanzak commented 1 year ago

Oh, ok. I thought it was a bug, but luckily I didn't submit the issue yet.

stepanzak commented 1 year ago

One last thing I forgot to write is that I have tried it with GNU Screen and Zellij and the error was only in Tmux. Hope that helps.

romkatv commented 1 year ago

OK, I see what's going on in there. Will fix later this week.

P.S.

wezterm.sh makes your prompt significantly slower. vte.sh does too. If you don't need all that stuff, keep setopt no_global_rcs in ~/.zshenv.

romkatv commented 1 year ago

Should be fixed now. Please update powerlevel10k and verify.

stepanzak commented 1 year ago

Yes, the error is gone. Awesome, thank you!

romkatv commented 1 year ago

Thanks for reporting, assisting in debugging end verifying!

stepanzak commented 7 months ago

Hi, the exact same thing happened again today. And removing /etc/profile.d/wezterm.sh fixed it again. I don't know if it's the exact same issue, but it looks like it is.

romkatv commented 7 months ago

I don't know if it's the exact same issue, but it looks like it is.

If it's the same issue, please use the same resolution. If that does not work, it's not the same issue, so please open a new issue.