Skip to content

fix(gh-r): musl detection is true whenever curl is installed #576

Description

@ss-o

Problem

In .zi-get-latest-gh-r-url-part (install.zsh:1653) the musl check is:

if (( ${+commands[curl]} )) || find /lib/ -maxdepth 1 -name '*musl*' >/dev/null 2>&1; then
  HAS_MUSL='linux-musl'
fi

The first operand tests whether curl is installed, which has nothing to do with libc. On any host with curl, including ordinary glibc Linux and macOS, HAS_MUSL becomes linux-musl and the find probe never runs.

The asset filter at install.zsh:1734 (${(M)list[@]:#(#i)*${~HAS_MUSL}*}) then narrows the candidate list to musl assets whenever more than one asset is still left. Checked in isolation: with HAS_MUSL=linux-musl and the assets tool-x86_64-unknown-linux-gnu.tar.gz and tool-x86_64-unknown-linux-musl.tar.gz, only the musl asset survives. So a gh-r install on a glibc host picks the musl build whenever a release publishes both. The filter only applies when it leaves at least one match, so it does not cause "no asset found".

Found by reading the code, with the filter step checked in isolation; not reproduced against a live release.

Change

Drop the commands[curl] operand so HAS_MUSL is set only when the host actually uses musl (the existing /lib/*musl* probe, or ldd --version). Also consider whether the anchored */$HAS_MUSL pattern at install.zsh:1710 can match any real asset URL at all.

Found during the 2026-09-30 whole-file review of install.zsh.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:ziZi core behavior, APIs, or documentation.type:bugSomething is broken or behaving incorrectly.

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions