zdharma-continuum / zinit

🌻 Flexible and fast ZSH plugin manager
MIT License
2.74k stars 122 forks source link

[bug]: Bad math expression in `zinit plugins` on Ubuntu-22.04/WSL2 #545

Closed arielsalvo closed 11 months ago

arielsalvo commented 11 months ago

What happened?

I found an error in the zinit plugins command on WSL2/Ubuntu-22.04/zsh-5.8.1 combo.

This is a fresh install, .zshrc only has zinit's installation and initialization (no plugins at all)

$ zsh
Cloning into '/home/***/.local/share/zinit/repo'...
remote: Enumerating objects: 20371, done.
remote: Counting objects: 100% (364/364), done.
remote: Compressing objects: 100% (170/170), done.
remote: Total 20371 (delta 258), reused 275 (delta 191), pack-reused 20007
Receiving objects: 100% (20371/20371), 12.59 MiB | 13.06 MiB/s, done.
Resolving deltas: 100% (12834/12834), done.
% zi plugins
==> Plugins
.zinit-list-plugins:18: bad math expression: illegal character: "
U %/home/***/.local/share/zinit/repo

Loaded: L | Unloaded: U

This does not happen on MacOS with zsh 5.9 but replicated on another machine with same setup.

Steps to reproduce

Just install zsh from apt in a fresh Ubuntu 22.04 on WSL2 on Windows 10 Create a .zshrc containing only the following:

ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit"
[ ! -d $ZINIT_HOME/repo ] && mkdir -p "$(dirname $ZINIT_HOME/repo)"
[ ! -d $ZINIT_HOME/repo/.git ] && git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME/repo"
source "${ZINIT_HOME}/repo/zinit.zsh"

Start zsh and wait until zinit is installed Run zi plugins

Relevant output

% zi plugins
==> Plugins
.zinit-list-plugins:18: bad math expression: illegal character: "
U %/home/***/.local/share/zinit/repo

Loaded: L | Unloaded: U


### Screenshots and recordings

_No response_

### Operating System & Version

OS: linux-gnu | Vendor: ubuntu | Machine: x86_64 | CPU: x86_64 | Processor: x86_64 | Hardware: x86_64

### Zsh version

zsh 5.8.1 (x86_64-ubuntu-linux-gnu)

### Terminal emulator

xterm-256color

### If using WSL on Windows, which version of WSL

WSL 2

### Additional context

_No response_

### Code of Conduct

- [X] I agree to follow this project's Code of Conduct
Ririshi commented 11 months ago

Seeing the same in a similar environment (Windows 11, WSL2, Ubuntu 22.04, zsh 5.8.1), but with more plugins installed.

❯ zi plugins
==> Plugins
.zinit-list-plugins:18: bad math expression: illegal character: "
U %/home/ririshi/.zinit/bin
.zinit-list-plugins:18: bad math expression: illegal character: "
U jessarcher/zsh-artisan
.zinit-list-plugins:18: bad math expression: illegal character: "
U romkatv/powerlevel10k
.zinit-list-plugins:18: bad math expression: illegal character: "
U zdharma-continuum/fast-syntax-highlighting
.zinit-list-plugins:18: bad math expression: illegal character: "
U zdharma-continuum/zinit-annex-bin-gem-node
.zinit-list-plugins:18: bad math expression: illegal character: "
U zdharma-continuum/zinit-annex-patch-dl
.zinit-list-plugins:18: bad math expression: illegal character: "
U zdharma-continuum/zinit-annex-readurl
.zinit-list-plugins:18: bad math expression: illegal character: "
U zdharma-continuum/zinit-annex-rust
.zinit-list-plugins:18: bad math expression: illegal character: "
U zsh-users/zsh-autosuggestions
.zinit-list-plugins:18: bad math expression: illegal character: "
U zsh-users/zsh-completions
Ririshi commented 11 months ago

I think there are some extra double quotes that are not correct inside (( )) in zinit-autoload.zsh#L1567:

(( "ZINIT[STATES__$i]" )) && is_loaded="{happy}L"

The above (current) version produces the error. It works fine after changing it to this:

(( ZINIT[STATES__$i] )) && is_loaded="{happy}L"
vladdoster commented 11 months ago

@Ririshi @arielsalvo,

Good catch. I wonder why this issue doesn't occur on macOS...?

If you have time, please test the bug fix via branch 545-bug-bad-math-expression-in-zinit-plugins-on-ubuntu-2204wsl2

Gerrit-K commented 10 months ago

@vladdoster @pschmitt what happened with this change on the main branch? It looks like there was a merge, then an attempted revert, but instead origin/main was hard reset ❔ Because I pulled from origin in between, my local main branch now diverged from origin and it appears that this also ended up in another branch (origin/fix/handle-bsd-realpath) image

I know how to easily fix this locally, but it might not be as obvious to everyone.