bartlomiejdanek / asdf-github-cli

MIT License
17 stars 8 forks source link

Installing GH cli fails with `Unrecognized archive format` #9

Open MPV opened 1 year ago

MPV commented 1 year ago
$ asdf install github-cli 2.28.0
Downloading github-cli from https://github.com/cli/cli/releases/download/v2.28.0/gh_2.28.0_macOS_amd64.tar.gz
Extracting /var/folders/wy/snw8djrd0ml_4d9gbb9dlqzw0000gn/T//gh_2.28.0_macOS_amd64.tar.gz
tar: Error opening archive: Unrecognized archive format

FYI, I have an updated plugin:

$ asdf plugin update github-cli
Updating github-cli to master
From https://github.com/bartlomiejdanek/asdf-github-cli
   9e0a9d7..e0605b7  master     -> master
   9e0a9d7..e0605b7  master     -> origin/master
Already on 'master'
Your branch is up to date with 'origin/master'.

Any ideas?

Have they moved?

$ curl -I https://github.com/cli/cli/releases/download/v2.28.0/gh_2.28.0_macOS_amd64.tar.gz

HTTP/2 404
server: GitHub.com
date: Wed, 14 Jun 2023 12:16:15 GMT
content-type: text/plain; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, Accept-Encoding, Accept, X-Requested-With
cache-control: no-cache
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; connect-src 'self'; form-action 'self'; img-src 'self' data:; script-src 'self'; style-src 'unsafe-inline'
x-github-request-id: DAB4:32F7:3224167:32C69F7:6489AF8F
MPV commented 1 year ago

Seems there's no tar.gz, only a zip nowadays for macOS? i.e. this one works: https://github.com/cli/cli/releases/download/v2.28.0/gh_2.28.0_macOS_amd64.zip

MPV commented 1 year ago

Not understanding yet why, but there's details here: https://github.com/cli/cli/issues/7470#issuecomment-1556986607

sfeuga commented 1 year ago

First of all, thank you for your work.

It seems there is an issue in the return of get_ext() and get_arch() functions when we use it via asdf, the extension is still set to tar.gz, when I tried to debug it locally (running the install file locally), I got a properly downloaded zip extension file.

Tested with the 2.31.0 version (macOS Ventura 13.4.1 (22F82) on m2 proc), on my mac, running uname -m return arm64 and:

But, running locally the install file (manually adding ASDF_INSTALL_VERSION=2.31.0 & ASDF_INSTALL_PATH=./temp_install just above the ASDF_INSTALL_TYPE=${ASDF_INSTALL_TYPE:-version } line) is working fine, but running it via asdf fail.

brianclin commented 1 year ago

When you tested it on a local script did you clone the repo or did you test it from ~/.asdf/plugins/github-cli/bin/install?

I would try removing the plugin and re-adding and see if that still fails.

sfeuga commented 1 year ago

When you tested it on a local script did you clone the repo or did you test it from ~/.asdf/plugins/github-cli/bin/install?

I would try removing the plugin and re-adding and see if that still fails.

I cloned the repo.

OMG!!! Removing/Re-adding fix the issue! Thank you (asdf plugin remove github-cli && asdf plugin add github-cli)

davividal commented 12 months ago

I have the same issue:

asdf install github-cli 2.34.0
Downloading github-cli from https://github.com/cli/cli/releases/download/v2.34.0/gh_2.34.0_macOS_arm64.zip
Extracting /var/folders/6x/n3txt2p104j975rykvmh5v3m0000gn/T//gh_2.34.0_macOS_arm64.zip
pigz: warning: <stdin>: entries after the first were ignored
tar: This does not look like a tar archive
tar: Skipping to next header
tar: Child returned status 1
tar: Error is not recoverable: exiting now

Looking at the source code, it seems that the installer is always trying to use tar, regardless of the type of archive. Maybe that is the issue?

Tar version:

tar --version
tar (GNU tar) 1.34
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.

GitHub-Cli archive:

file gh_2.34.0_macOS_arm64.zip

gh_2.34.0_macOS_arm64.zip: Zip archive data, at least v2.0 to extract, compression method=deflate
brianclin commented 12 months ago

It works with

~ ❯ tar --version                                  
bsdtar 3.5.3 - libarchive 3.5.3 zlib/1.2.11 liblzma/5.0.5 bz2lib/1.0.8 

The install script would need to be updated to use unzip for .zip if you're using GNU tar

frealmyr commented 6 months ago

A workaround for those on MacOS with gnu-tar installed, is to add the following to ~/.asdfrc:

pre_asdf_install_github-cli = export PATH=/usr/bin:${PATH}

Install should then use bsdtar for extracting:

[~]λ asdf install github-cli latest
Downloading github-cli from https://github.com/cli/cli/releases/download/v2.44.0/gh_2.44.0_macOS_arm64.zip
Extracting /var/folders/0n/qs1x3zyn2kb9y_cqks96fr8r0000gn/T//gh_2.44.0_macOS_arm64.zip
Moving bin to /Users/frealmyr/.asdf/installs/github-cli/2.44.0/bin/gh
Cleaning tmps...
Run: asdf <global | local> github-cli 2.44.0
jaymecd commented 6 months ago

@frealmyr saved my day, works like a charm with bsdtar. Nevertheless it's just a workaround, proper fix is still needed.

ssbarnea commented 4 days ago

We really need a fix for this as we cannot rely on workarounds like this for CI/CD.