Skip to content

Bug: gitlab-cli feature fails for recent glab versions due to lexicographic version comparison bug #729

Description

@Shamazo

The gitlab-cli feature fails to install when version resolves to a glab release ≥ 1.100.0 (including latest, currently 1.106.0), because install.sh uses bash's string comparison operator to decide which asset-naming scheme to use:

if [[ "${CLI_VERSION}" < "1.47.0" ]]; then
    arch="${arch:-$(uname -m)}";
else
    arch="${arch:-$(dpkg --print-architecture | awk -F'-' '{print $NF}')}";
    os="${os,,}";
fi

[[ ... < ... ]] compares strings lexicographically, not as version numbers. For CLI_VERSION=1.106.0, comparing against "1.47.0" character-by-character hits '1' < '4' at the third character, so the expression evaluates true even though 106 > 47. This sends the script down the old branch, producing filenames like glab_1.106.0_Linux_x86_64.deb, which no longer exists on GitLab's release server (current assets use glab_1.106.0_linux_amd64.deb). The install then fails with a 404.

Repro:

$ echo '[[ "1.106.0" < "1.47.0" ]] && echo old || echo new' | bash
old

Suggested fix: Replace the string comparison with a proper version comparison, e.g. sort -V or dpkg --compare-versions "${CLI_VERSION}" lt 1.47.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions